to safe browsing.

How to redirect you website with 301 Redirection

June 28, 2008 – 1:23 pm | by admin

You have change your URL of domain and now want that all traffic of old site should come to new URL. Or you have sub domain and now want to redirect all the traffic of sub domain to your main domain. Also you want the page rank (PR) should automatically assign to new domain. So you can do it very easily. There is an option exists which is called redirection of URL either permanent or temporary.

What is 301 redirect?

There are two types of redirection exists. One is temporary also call 302 redirect and other is permanent redirection called 301 redirect. 301 Redirection is very friendly and recommended by Search Engines. With this technique all of your old pages in search engine automatically redirect to new URL. Also the page rank (PR) and visitors never disturb.

How to activate 301 Redirect on website?

Now, it is important that i want to set 301 redirect on my domain but HOW?

For this, there are two types to implement 301 redirect. If you have access on Apache module then just add the rule in apache configuration. But as most of the sites are hosted on other server and they don’t have access to change apache configuration. Then, there is another option that you can set the redirect rule in .htaccess file.

What is .htaccess file?

.htaccess file is located in the root folder of domain. If you don’t have .htaccess file on your domain root folder. Simply create .htaccess file (remember this file has not any extension) and upload it to your server after writing the re-write rule.

If you have already .htaccess file then download the file on your computer and change it accordingly and upload it.

How to write re-write rule for 301 Redirect?

1. To redirect ALL files on your new domain use this in your .htaccess file if you are on a unix/linux web server:

redirectMatch 301 ^(.*)$ http://www.newdomain.com
redirectMatch permanent ^(.*)$ http://www.newdomain.com

You can also use one of these in your .htaccess file:

redirect 301 /index.html http://www.newdomain.com/index.html
redirect permanent /index.html http://www.newdomain.com/index.html
redirectpermanent /index.html http://www.newdomain.com/index.html

This will redirect “index.html” to another domain using a 301Redirect permanently redirect.

2. If you need to redirect http://mydomain.com to http://www.mydomain.com and you’ve got mod_rewrite enabled on your server you can put this in your .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]

or this:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

Tip: Use your full URL (ie http://www.domain.com) when obtaining incoming links to your site. Also use your full URL for the internal linking of your site.

3. If you want to redirect your .htm pages to .php pages and you’ve got mod_rewrite enabled on your server you can put this in your .htaccess file:

RewriteEngine on
RewriteBase /
RewriteRule (.*).htm$ /$1.php

4. If you wish to redirect your .html or .htm pages to .shtml pages because you are using Server Side Includes (SSI) add this code to your .htaccess file:

AddType text/html .shtml
AddHandler server-parsed .shtml .html .htm
Options Indexes FollowSymLinks Includes
DirectoryIndex index.shtml index.html

All the above are the method which you can use manually to write .htaccess file to redirect your domain from old URL to new URL. But if you have CPanel to configure your domain settings then you can do it easily from CPanel by click on Redirect.

Tags:

Post a Comment