how do i show 404 error page without showing the error page's url?

一个人想着一个人 提交于 2019-12-24 03:32:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!