如果出现错误,将网页重定向到某个预定义的网页

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 not 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.