301 redirection is probably one of the most frequently asked questions when we talk about redirections. Besides, we could say that the 301 redirection is one of the things that need to be done if we want to:
- redirect the old domain to a new one
- correctly organise the URL structure by selecting www. or without the www prefix
- set redirection from several domains to only one site
- help search engines to reindex the site which was transferred to the new domain using multiple redirections
One of the reasons the 301 redirections must be done is the fact that takes only 5 minutes (ok, let’s rule out the situation where you need to redirect about 500 different URLs), some good will — and instructions on the process of redirection. I’ll show you how this process can be done, but really, it shouldn’t take longer than a couple of minutes for each one to be done…
Redirection of an old domain to a new one
This method applies if you are using Linux hosting, and the server gives you the option of mod_rewrite. In case you are not sure that mod_rewrite is available, a check can be done this way. After that, create the .htaccess file to which you will copy the next code and save it to the root directory:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.novadomena.com/$1 [R=301,L]
Redirection of non-www to www version
Copy into .htaccess file:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domena.com [nc]
rewriterule ^(.*)$ http://www.domena.com/$1 [r=301,nc]
Insert into .htaccess file will enable redirection from non-www to www version. The reason this method is applied is explained on this blog, but it won’t do any harm to repeat it:
- because of the difference in the domain prefix, some deviations in the number of backlinks and PageRank are possible because, technically, it is about two different domains (links).
PHP redirection
In case you need redirection of one file, it can be done by entering the following code into the same page:
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.novi-url.com” );
ASP redirection
For ASP users, the method from above should look like this
<%@ Language=VBScript %>
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.novi-url.com/”
Redirection with WordPress
For WordPress fans, there is a plugin that helps you to make 301 redirections.