Home arrow JavaScript arrow Page 2 - Server-side redirects: .htaccess versus Meta Redirects
JAVASCRIPT

Server-side redirects: .htaccess versus Meta Redirects


URL redirects are needed for a number of reasons. One example is when you have changed significant portions of your website, and then have to deal with the problem of people finding their way from the old pages to the new pages. There are different ways of redirecting pages, through Meta tag http-equiv, JavaScript or any of the server-side languages. And what’s more, you can do it through .htaccess, which is probably the most effective, considering the minimal amount of work required to do it.

Author Info:
By: Stephen Davies
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
November 28, 2007
TABLE OF CONTENTS:
  1. · Server-side redirects: .htaccess versus Meta Redirects
  2. · How .htaccess can help you: Custom Error Pages
  3. · Password Protection / Authentication
  4. · Enabling SSI (Server-Side Includes)
  5. · Redirects
  6. · Pros and Cons

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Server-side redirects: .htaccess versus Meta Redirects - How .htaccess can help you: Custom Error Pages
(Page 2 of 6 )

Here are some common uses of the .htaccess file. These will allow you to have your own personal error pages (for example when a file is not found) instead of using your host’s error pages or having no page. This will make your site seem much more professional in the unlikely event of an error.

It will also allow you to create scripts to notify you if there’s an error. For example, you can create a JSP script on your own website to automatically e-mail you when a page is not found.

You can use custom error pages for any error as long as you know its number (like 404 for page not found, 403 for forbidden and 500 for server internal error) by adding the following to your .htaccess file:

ErrorDocument errorNumber /path/file.html

For example, if I had the file not_found.html in the /errors directory of my site and I wanted to use it for a 404 error I would use:

ErrorDocument 404 /errors/not_found.html

Another example is if I had made a JSP script that will automatically send me an e-mail notification when a server internal error has occurred on my site, and I put the script in the path: /utility/mailer.jsp, I would use:

ErrorDocument 500 /utility/mailer.jsp

Additionally, you can use an external page to customize your error. For example when you found a 404 Not Found page on Yahoo, and you wrote down the URL: http://www.yahoo.com/errors/404.html, you would modify your .htaccess file content as follows:

ErrorDocument 404 http://www.yahoo.com/errors/404.html

With this code, when a bad request comes to your website, it will be navigated to http://www.yahoo.com/errors/404.html


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 1 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials