开发者

How can i show a 404 error from Apache when .php does not exist

I have WP site开发者_如何学JAVA with redirects setup as follows :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]
</IfModule>

Which works fine for all URLs. But if i access a url like "/file/does/not/exist.php" it shows a WP 404 error page. I dont want that request to reach WP, it should show a 404 from apache.

So "/file/does/not/exist" should go to WP 404 page (it does) but "/file/does/not/exist.php" should be a 404 from Apache.


That kind of conflicts with the !-f RewriteCond ("not a file"). A missing script is not a file, therefore it satisifies the rewrite condition. You may have to specifically check if the filename contains '.php' and not rewrite to wordpress. But what if someone tries to access some other file extension which should also be a 404?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜