View Single Post
  #2 (permalink)  
Old 01-10-2005, 11:35 AM
minstrel's Avatar
minstrel minstrel is offline
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: Ottawa, Canada
Posts: 2,554
minstrel RepRank 2minstrel RepRank 2
Default

Quote:
Or, should I redirect the domain and every individual page of the current website to the corresponding page on the new domain(is this possible, guess i'll need to mess with the .htaccess for this), if so could someone tell what is the most SE friendly way to do it on a linux server, if it is really required.
You can do a whole site redirect using .htaccess (see below). Alternatively, you can redirect each individual page with a displayed message for human visitors that the page has been moved using the "refresh" meta tag (see below). Either way, if there are a lot of backlinks to the site or to individual pages on the site, you will want to contact the webmasters of the pages in question and ask them to update the links.

Quote:
Search engine friendly redirect (301 redirect)
There are many types of redirect but some methods can be considered 'trickery' by the search engines simply because they can be used to fool the search engine by some people. The main search engine in question is Google, and it considers a 301 redirect to be the proper redirect, because it tells the search engine that the content that it expected to get at site A has permanently moved to site B therefore it will be redirected there.

A 301 redirect is executed server-side which means that the visitor is never aware that they have been redirected, there is no time delay like with javascript

301 redirect in PHP
To use the following PHP code you must change the file extension of the file you will be using to index.php instead of index.html.

Now put the following code into your new index.php page, put ONLY this code, no need for <head>, <body> or any other tags.

Change www.newdomain.com/page.html to the url the page will be redirecting to
Code:
<?php
header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://www.newdomain.com/page.html"); 
exit(); 
?>
301 redirect in ASP (only microsoft web servers)
[code]To use the following ASP code you must change the file extension of the file you will be using to default.asp instead of default.html.

Now put the following code into your new default.asp page, put ONLY this code, no need for <head>, <body> or any other tags.

Change www.newdomain.com/page.html to the url the page will be redirecting to

Code:
<%
response.Status = "301 Moved Permanently"
response.addheader "location", "http://www.newdomain.com/page.html"
response.end
%>
301 redirect through mod-rewrite in your .htaccess file
This is by far the best 301 redirect, new to .htaccess? go over to the .htaccess tutorial to learn more about it.

OK here's how you make a .htaccess file and put mod_rewrite in it:

Open up notepad (or a text editor in which you can save in plain text) and then put the following code in it

Code:
RewriteEngine On
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
Replace newdomain with the domain name you want to redirect to

Save it with any name, upload it your your server and then rename it to .htaccess, with the "." in front.

Changing the domain's nameservers to point to the new url
Another safe way to get an old/second domain to go to a different hosting account/website is to park the old domain name and change its nameservers to point it to the new one.

Your host will provide you with these nameservers, and will look something like ns1.domain.com, there's usually two.

Log in to your control panel at the registrar where you bought the domain and there will be a menu option to change the nameservers, enter the new nameservers, hit save

Enter your hosting control panel for the website the domain will be pointing to and you will need to add the domain as a parked domain, under the setting of the same name

Wait for the new settings to propagate (take effect) anywhere up to 48 hours, and it should redirect to the other website no problems
Note: this is modified from something I found on the net a while back and, unsually for me, I neglected to save the URL in my local text file. If anyone knows the source, please let me know so I can credit the author.
Reply With Quote