Home arrow JavaScript arrow Page 5 - 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 - Redirects
(Page 5 of 6 )

 

The last feature of widespread use is the Redirect. Redirect is the most useful feature that .htaccess provides, either on the same server, or on a completely different web site. It can be extremely useful if you change the name of one of your files but still allows users to find it. Another use, which I find very useful, is to redirect to a longer URL, for example:

Redirect /jump/url1.ext http://www.otherlongsite.com/new/file/locations.xyz

To show you another example, let us suppose that your current web site domain is yoursite.com and now you registered another domain at yoursite.net, and you expect any requests to yoursite.net will be forwarded to yoursite.com. This means the whole site redirects, so you need to add a "follow" directive to the .htaccess and place it at the root of yoursite.net.

Redirect / http://www.yoursite.com/


When a user requests a URL, e.g. http://www.yoursite.net/news/daily.html, the browser address will be forwarded to http://www.yoursite.com/news/daily.html. Also a request for http://www.yoursite.net/album/index.jsp will be forwarded to http://www.yoursite.com/album/index.jsp.

Meta tag redirection

Now you have seen the basic functionalities that .htaccess provides, let us talk about another way to redirect by the use of Meta tags.

Here is an example index.html:


<html>

<head>

<title>Welcome</title>

<meta http-equiv=”refresh” content=”5; url=http://www.newsite.com/” />

</head>

<body>

This page has moved.<br />

Please follow the link to the new location<a href=”http://www.newsite.com”>http://www.newsite.com/</a>

</body>

</html>



Your old site’s home page would be updated with the above code. All users coming to the root of the old site will be automatically forwarded to the new site,  http://www.newsite.com after 5 seconds.


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 5 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials