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
Here are some other redirect tutorials
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
<?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)
- 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
<%
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
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.
- there you have it, now all attempts to enter any file on the old domain will redirect to your newdomain instantly
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 change it's namerservers.
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
You may not have bought your domain from a registrar but from the hosting company, in this case contact them, they will do it for you.
If you would like to purchase a domain do so from one of these trusted registrars
