Home     SSI Lab     CSS Templates     CSS     Htaccess     Web Design     XHTML

Design Tutorials

graphic-img   



Redirecting a Page

Bookmark with StumbleUpon
del.icio.us
Digg it
reddit
Furl
Spurl
ma.gnolia
Yahoo MyWeb
Windows Live
Sponsors

How to automatically redirect a page to another address.

This simple guide shows you two ways of redirecting a web page to a different web page.

Tested in Mozilla Icon Opera Icon IE6 Icon



Method 1::

This first example is useful if you want to inform your visitor that you have moved.

Into the HEAD section of your page type:

<meta http-equiv="refresh" content="5; URL=http://my_new_web_address">

And then into the BODY of your document put:

"My_old_web_address" has moved to "My_new_web_address"
If your browser does not automatically redirect you in 5 seconds, click <a href="http://my_new_web_address">here</a> to go to the new site.

You don't need to display a message and can just redirect quickly by setting the time to zero, but it's polite to inform your visitor! :)



Method 2::

The second example using java script is handy if you have a number of domain names (for whatever reason) but want all names to point to the same domain.

Just add this to the top of your document:

<script language="JavaScript">
<!--
if( -1 == location.href.
toLowerCase().
indexOf('your-domain.fi') )
{
location.href = 'http://your-domain.fi';
}
// -->
</script>

The above code will check if 'your-domain.fi' is part of the code and if not will immediately redirect to 'http://your-domain.fi'

Option 2 is best I think unless you want to actually inform your visitor of the change then option 1 can be a good idea.