0

書き換えをオフにすると、想定どおりに 404 が Google に正しく送信されます (テストのためだけに使用されます)。オンの場合、最初に書き換えが実行され、ErrorDocument 宣言が完全に無視されます。なぜこれをしているのか理解できません。

Options +FollowSymlinks
ErrorDocument 404 http://www.google.com
<IfModule mod_rewrite.c>
RewriteEngine Off
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
4

2 に答える 2

1

さて、あなたの以下.htaccessは言っています

RewriteCond %{REQUEST_FILENAME} !-f     # if not a file
RewriteCond %{REQUEST_FILENAME} !-d     # if not a directory
RewriteRule . /index.php [L]            # redirect to index.php

したがって、これらのルールを削除するか、書き換えエンジンをオフにしてください。

編集:
リンク構造が物理的に存在しないため、パーマリンクは 404(s) をキャッチすることによって機能します。ErrorDocumentが.mod_rewrite_ 404例えば、

RewriteCond %{REQUEST_FILENAME} !-f     # if not a file
RewriteCond %{REQUEST_FILENAME} !-d     # if not a directory
RewriteCond %{REQUEST_URI} ^/wordpress/ # & points to wordpress
RewriteRule . /index.php [L]            # redirect to index.php

これで、 adomain.com/wordpress/no-such-file.phpは にリダイレクトされますが、Google にリダイレクトされます ( のため/index.php) 。domain.com/no-such-file.phpErrorDocument

于 2013-07-15T21:01:10.197 に答える