开发者

custom 404 page for nonexistent php files

开发者 https://www.devze.com 2022-12-10 23:02 出处:网络
I just tried to redirect nonexistent files on the server to my custom 404 page but it only redirects .html files.

I just tried to redirect nonexistent files on the server to my custom 404 page but it only redirects .html files.

I used that in my .htaccess file:

ErrorDocument 404 /404/404.html

How can I redirect all nonexistent files (including .php开发者_C百科) to my custom page?

Thanks


This should redirect all nonexistent files in the same directory as that .htaccess file. What happens in case a nonexistent PHP file is requested?


It could be that some other rule or directive (for example, a redirect) processes the PHP files before it gets to your ErrorDocument directive. Without more information, this is impossible to tell.


Try that:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteuRule .* home.html [L]

If you wants 404 redirection RewriteuRule .* home.html [R=404,L]

0

精彩评论

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

关注公众号