March 31, 2015

Redirect users to customized Error pages in PHP

PHP is the most power language used to create dynamic web pages. It's a Server side scripting language. We can create very secured web sites using PHP. Anyway I am not going to discuss everything about php. In this post I am giving you how to redirect the user for your customized error documents.
There is a file named .htaccess file in php if not their you can create one. .htaccess is not an extension, it's a file name it self. There is nothing like filename,htaccess it's only .htaccess. You have to create that file and put that file in your working directory.
Now open .htaccess file in the code editor paste the following lines.

ErrorDocument 401 /error_pages/401.html
ErrorDocument 404 /error_pages/404.html
ErrorDocument 500 /error_pages/500.html


Let me explain the meaning of above lines. ErrorDocument 404 says the following link is link to the error document and redirect the user to that page when ever the error 404 occurred.
error_pages/404.html is a path to the customized 404 error file and you can give it any name you like. Again no need to remember about the different types of error pages available you can search in the internet or if you wait for a few time I will post about them in our blog.

So, this is it guys. Any queries don't hesitate to comment below or mail me at ething4pc@gmail.com


No comments: