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.
Next: Pros and Cons >>
More JavaScript Articles
More By Stephen Davies