LoginSignup
1
2

More than 5 years have passed since last update.

X-Frame-Options で複数ドメインを指定する方法

Last updated at Posted at 2018-11-19

基本的に1つしか指定できないので、条件に応じて出し分ける必要がある。

security.conf
# 正規表現でマッチしたURLを環境変数に入れる
SetEnvIf Referer "^(https:\/\/*\.example\-1\.com)/.*" X_FRAME_OPTIONS_ALLOWED=$1
SetEnvIf Referer "^(https:\/\/*\.example\-2\.com)/.*" X_FRAME_OPTIONS_ALLOWED=$1

# マッチしなかった場合(環境変数に値がない場合)はDenyを指定する
Header set X-Frame-Options Deny env=!X_FRAME_OPTIONS_ALLOWED

追記

ALLOW-FROM はChromeやFirefoxが対応していないそうなので削除しました。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2