.htaccessの動作について
example.comにワードプレスをインストール
example.com/test1にワードプレスをインストール
example.com/test1にインストールしたワードプレスに画像をアップロード
example.com/test1にアップロードした画像にURLを直接入力してアクセスしようとしたときにerror.pngに転送する。
#/リファラがブランク時のアクセスを否認 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} ^$ RewriteCond %{REQUEST_FILENAME} !/example\.com/public_html/test1/wp-content/uploads/2016/11/error\.png$ RewriteRule ^(.*)\.(gif|jpg|png)$ http://www.example.com/test1/wp-content/uploads/2016/11/error.png [L] </IfModule> #/リファラがブランク時のアクセスを否認
/example.com/public_html/.htaccess
に追記
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} ^$ RewriteCond %{REQUEST_FILENAME} !/example\.com/public_html/test1/wp-content/uploads/2016/11/error\.png$ RewriteRule ^(.*)\.(gif|jpg|png)$ http://www.example.com/test1/wp-content/uploads/2016/11/error.png [L] </IfModule> ```この場合はerror.pngにリダイレクトされません。 /example.com/public_html/test1/.htaccess に追記 ```.htaccess # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /test1/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /test1/index.php [L] </IfModule> # END WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} ^$ RewriteCond %{REQUEST_FILENAME} !/example\.com/public_html/test1/wp-content/uploads/2016/11/error\.png$ RewriteRule ^(.*)\.(gif|jpg|png)$ http://www.example.com/test1/wp-content/uploads/2016/11/error.png [L] </IfModule>
この場合はerror.pngにリダイレクトされます。
.htaccessは記述した場所の配下に影響を与えると思っています。
/example.com/public_html/.htaccess
が
/example.com/public_html/test1/.htaccess
に上書きされるため
/example.com/public_html/.htaccess に 追記しても
error.pngにリダイレクトされないのでしょうか??
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/11/27 08:37