开发者

Redirecting webpage to some pre-defined webpage in case of errors

Suppose the user try to access the following web page on my website

http://something.com/hello/hi.php

But hi.php webpage does not exists on the server. Instead of web-browser showing that "this page does not exist", I want to redirect the user to some predefined page (say nofound.php) on which I will beautifully display the message "page you are trying to access does n开发者_如何学运维ot exists"

How can I redirect a user to some predefined web-page in case of "page not found" error?


You should use a directive in your .htaccess file.

ErrorDocument 404 /your4040page.html


If you are using Apache you can take a look at ErrorDocument directive.

Many frameworks (Symfony, CakePHP, Rails,...) implement their own mechanisms to handle 4xx and 5xx errors (among others). You can take a look at them as well and adapt them to your particular requirements.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜