How can I set up a auto-redirect from one site to another?

I have a website that I recently setup and have running, but I want people to be able to type in www.thisonefirst.com and end up on www.thisonesecond.com (both are fake)...

Can anyone help? If you need more information, ask for it!

Mike2008-03-27T05:58:51Z

Favorite Answer

There's various ways to do this, you can use :

HTML :
<meta http-equiv="refresh" content="2; url=http://www.thisonesecond.com">


Javascript :
<script type="text/javascript">
<!--

window.location = "http://www.thisonesecond.com/"

//-->
</script>

Both those html and javascript methods are a bit slow and clunky, you have to wait for the page to load before you get redirected.

A far better method is to send a '301 moved' http header, you can do this with server side scripting, such as php

<?
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: http://www.thisonesecond.com');
?>

That will send a 301 Moved header to the browser, the browser will then go off to the new location.

Another method is to use a .htaccess file with apache (assuming your web server is apache that is) to do the 301 trick, this has the advantage of forwarding any page on your old site to the new site. Create a file called .htaccess containing

RewriteEngine On
Redirect 301 / http://www.thisonesecond.com/

A benefit of the '301' method is that search engines such as google will take note of the '301 Moved' header and update their results to point to the new site.

knickar2008-03-27T06:00:58Z

<html>

<head>
<title>Meta Redirect Code</title>
<meta http-equiv="refresh" content="5;url=http://www.somewhereelse.com">
</head>
<body>
Your browser will be automatically redirected to the new site.
</body>