Welcome to WeetHet!


Managed Web Hosting by Liquid Web

Your IP address:
44.221.43.208
     
 
Print this page
- use Landscape
Search the
WeetHet Pages
WeetHet is being updated! - Current articles will slowly move to www.tweaking4all.com
For excellent webhosting that is reliable and affordable, we highly recommend: LiquidWeb

On this page ...

Automatically redirect to a different location

I'm not sure all of you readers have experienced this, but I for sure now I did.

I had to move my entire website to a better location (ie. move it to a different location). So how do I redirect people from my old site automatically to my new website ?

Note: if your server supports either Frontpage-extensions or a .htaccess file, then consider using these options.

HTML

Move ...

Let's use JavaScript again and see how it is capable of doing something like that for you:

<script>
<!--
function autoChange()
{
var timeID = setTimeout("location.href= 'http://www.newlocation.com'", 1)
}
//-->
</script>

This little script will wait 1 millisecond and then jumps to http://www.newlocation.com.

The delay time (indicated in the color red) can be altered to for example 1000 milliseconds.

Just copying this code will not do the job ! We need to trigger this procedure. This is done by adding "autochange()" to the OnLoad-event of your HTML file.

Add this event to the <BODY> tag as shown below:

<body onLoad="autoChange()">

In this example I set the OnLoad-event to execute the script we just have seen.
A full page HTML file would be similar to this one:

<HTML>
<script>
<!--
function autoChange()
{
var timeID = setTimeout("location.href= 'http://www.newlocation.com'", 1000)
}
//-->
</script>
<BODY onLoad="autoChange()">
Welcome to my website,... unfortunally we moved it to WWW.NEWLOCATION.COM.<BR>
Your browser will automatically jump there.<BR>
If it doesn't then please click <A HREF="http://www.newlocation.com">here</A> to go there.
</BODY>
</HTML>

This page will display a warning that the website moved and that the browser will go there automatically.

Just for those browsers that do not support JavaScript, we add an additional link including the link to the new site so they can click there.

Note: naturally, this HTML file should be placed on the OLD website or in place of the OLD file!


 

 


Klik hier om te wisselen naar nederlandstalige pagina's You are currently on the English pages.