如何显示404错误页面而不显示错误页面的URL? [英] how do i show 404 error page without showing the error page's url?
本文介绍了如何显示404错误页面而不显示错误页面的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我的用户键入不存在的页面(例如
when my users type a non-existent page such as
www.example.com\wrongurl.html
我希望用户看到404错误页面.但网址不应更改.
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]
我该怎么做?
推荐答案
尝试以下规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /404.html [L,NC]
这会在内部将对不存在的文件/目录的请求重定向到404.html页面.
This internally redirects a request for non-existing file/directory to 404.html page.
这篇关于如何显示404错误页面而不显示错误页面的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文