重定向一个不存在的URL错误页 [英] Redirect a non-existing url to error page
问题描述
我要重定向所有非可链接至error.php页
这里就是我想要的
如果有人进入了一个不存在的话,而不是虚拟主机提供商的404错误页面的链接,我想将它们重定向到我的错误页面
www.example.com/wrong_page.php
应该被重定向到
www.example.com/error.php
您有2个选择,一个错误的 REQUEST_URI
重定向到错误页面
1)内部重定向
您的Web服务器将在内部重定向错误的请求错误页面,
在试试这个你的WebRoot /的.htaccess
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^(。*)$ /error.php [NC,L]
2)外部重定向
您的Web服务器将外部重定向错误的请求错误页面,
还是在尝试这是你的的WebRoot /的.htaccess
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^(。*)$ http://example.com/error.php [R,NC,L]
重写条件检查请求的文件名不是一个目录或文件,然后重写规则将其重定向到错误页面。
I want to redirect all non available links to the error.php page
here is what I want
if someone entered a link that does not exist ,then instead of 404 Error page of webhost , I want to redirect them to my error page
www.example.com/wrong_page.php
should be redirected to
www.example.com/error.php
You have 2 options to redirect a Wrong REQUEST_URI
to the error page
1) Internal Redirect
Your web server will internally redirect a wrong request to the error page,
Try this in your WebRoot/.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /error.php [NC,L]
2) External Redirect
Your web server will externally redirect a wrong request to the error page,
Or Try this in your WebRoot/.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://example.com/error.php [R,NC,L]
Rewrite conditions check if the Requested filename is not a directory or file ,then RewriteRule will Redirect it to the error page.
这篇关于重定向一个不存在的URL错误页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!