问题
when my users type a non-existent page such as
www.example.com\wrongurl.html
I want users to see 404 error page. But the URL should not change.
I have tried the following but doesn't work.
ErrorDocument 404 http://www.example.com/404.html
RewriteEngine On
RewriteRule 404/ http://www.example/404.html [NC]
How can i do this?
回答1:
Try the following rules :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /404.html [L,NC]
This internally redirects a request for non-existing file/directory to 404.html page.
来源:https://stackoverflow.com/questions/31231265/how-do-i-show-404-error-page-without-showing-the-error-pages-url