Sunday, February 28, 2010

Htaccess Custom Error Pages

Many of U may have a website. So this is something that U might know, but if U don't then this might B a little helpful 2 U.
Do U know what happens when a user enters D url of a page that is not present on your server???
Well in normal cases & in most cases, D user will see a 404 Error (File Not Found) Page generated by D browser. Now that is really annoying as D user has 2 go back & find another page. So what is D solution.
Simple just follow the steps & U'll get results that'll make your site look more professional.
  1. Create a page with D theme of your site. U can add anything like ads, menus, just think what U want 2 do with a page.
  2. Next save it with a suitable name like 404.html.
  3. Create a text file and save it as htaccess.txt.
  4. In htaccess.txt type, ErrorDocument 404 /404.html
  5. Save all the files & upload them on your server in your main directory.
  6. IMPORTANT : Rename D htaccess.txt to .htaccess (do not add any extension)
  7. Done now if the user types any url that is not found, then D user will B directed 2 this custom page.
One more thing many servers have their own .htaccess file, if they use access database. Then U might have 2 edit D existing file. If U do that then it might cause some problems & in that case don't blame me.

Now U can also make custom pages 4 any error, just add another line ErrorDocument 404 /404.html & replace D 404 with D error U want 2 make D page 4 & 404.html with D page name.
Here are a short list of error numbers:
  1. 400 - Bad Request
  2. 401 - Not Authorised
  3. 403 - Forbidden
  4. 404 - Not Found
  5. 408 - Request Timeout
  6. 410 - Gone
  7. 415 - Unsupported Media Type
  8. 500 - Internal Server Error
  9. 503 - Service Unavailable
If U have any other problem then U can always ask me.

No comments:

Post a Comment