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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect from old site to new site. 2

Status
Not open for further replies.

compxinu

MIS
Sep 20, 2004
40
US
When a user goes to a site that has moved, they get a message at the old site:

"This site has moved to you will be redirected to the new site in 5 seconds."

What is the code that actually forces the redirect?

Thanks.
 
My guess is a meta refresh.

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Exactly what I meant, except without code.

--Chessbot

"So it goes."
Kurt Vonnegut, Slaughterhouse Five
 
Depending on your reasons for the redirect, and how much importance you put on your site's Search Engine friendliness you may be better off setting up a 301 redirect to the new page.

You can do this either via your server config (if you have access to it), by setting up an .htaccess file or by using a scripting language such as PHP or ASP.

For expample. I had a page on my site called "blog.php". I changed this when I redesigned my site and wanted requests for blog.php to go to rant.php.
I used this code, and nothing else, in blog.php.

Code:
<? //301 redirect for blog page to rant page
header("HTTP/1.1 301 Moved Permanently");
header("Location: [URL unfurl="true"]http://www.foamcow.com/rant.php");[/URL]
header("Connection: close");
?>

I have done a similar thing using ASP for another site.

A 301 redirect will tell any "bot" that the page has moved permanently and to use the new URL next time it wants to reach the page. It will also redirect any browser request for that page to the new one.

I don't think Search engine bots particularly like META refresh tags as they were abused by spammers.

The 301 is a "better" way to do it, but if you want a quick and dirty redirect, there is nothing really wrong with the META refresh.

"I'm making time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top