Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I redirect my website to another address??

Redirecting my page.

How do I redirect my website to another address??

by  cian  Posted    (Edited  )


Here are just two simple ways to redirect your page!



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:

Code:
<meta http-equiv="refresh" content="5; URL=http://my new web address">

And into the BODY of your document put

Code:
"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.


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:

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

The above code will check if 'mydomainA.com' is part of the code and if not will immediately redirect to 'http://mydomainA.com'

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.



I apologise for any errors or ommisions.
Questions or feedback would be greatly appreciated.

+
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top