views:

48

answers:

5

Hi friends,

I am developing a website in php.

when a user types a page which is not in my site, i want users to redirect to a page with an error message.

how can i identify such things and how can i do this??

Thanks.

+1  A: 

If you're using Apache web server, you get this functionality for free. No need to implement it yourself. If the web server cannot find an resource it sends the client an HTTP 404 error (not found). Actually, pretty much any web server that correctly implements HTTP (1.0 or 1.1) will behave this way. Additionally, in Apache, you can customize the 404 page.

Asaph
A: 

This is not really a php feature, but more of a feature of your web server. In IIS you can configure the error page to go to a custom url. In apache i think you can usr mod_rewrite to achieve the same thing

My Other Me
A: 

If you're using Apache, here's instructions: http://www.thesitewizard.com/archive/custom404.shtml

Matt
A: 

Other than what others said this might be of some help too "Custom 404 Error" if you are using Apache.

Shoban
A: 

If some script is launched on all of your pages (it can me unit, which is always included) you can make a check there. You should write there all of your available pages and if the required page is not in the list - you can show person, that he/she was wrong.

Sometimes the list of pages is jept in database. Most CMS-systems are based on that.

Eamon