Sep 1, 2009

Process of 301 Permanent Redirect

How to implement the 301 Redirect at htaccess level:


1. To create a .htaccess file, open notepad, name and save the file as .htaccess (there is no extension).

2. If you already have a .htaccess file on your server, download it to your desktop for editing.

3. Place this code in your .htaccess file:

redirect 301 /old/old.htm

4. If the .htaccess file already has lines of code in it, skip a line, then add the above code.

5. Save the .htaccess file

6. Upload this file to the root folder of your server.

7. Test it by typing in the old address to the page you've changed. You should be immediately taken to the new location.

Notes: Don't add "http://www" to the first part of the statement - place the path from the top level of your site to the page. Also ensure that you leave a single space between these elements:

redirect 301 (the instruction that the page has moved) /old/old.htm (the original folder path and file name) (new path and file name)

When the search engines spider your site again they will follow the rule you have created in our .htaccess file. The search engine spider doesn't actually read the .htaccess file, but recognizes the response from the server as valid.

During the next update, the old file name and path will be dropped and replaced with the new one. Sometimes you may see alternating old/new file names during the transition period, plus some fluctuations in rankings. According to Google it will take 6-8 weeks to see the changes reflected on your pages.

Other ways to implement the 301 redirect:

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

redirectMatch 301 ^(.*)$

redirectMatch permanent ^(.*)$

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

redirect 301 /index.html
redirect permanent /index.html
redirectpermanent /index.html

This will redirect "index.html" to another domain using a 301-Moved permanently redirect.

2. If you need to redirect to 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 ^(.*)$$1 [R=permanent,L]

or this:

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

Tip: Use your full URL (ie 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

IIS Redirect

  • In internet services manager, right click on the file or folder you wish to redirect
  • Select the radio titled "a redirection to a URL".
  • Enter the redirection page
  • Check "The exact url entered above" and the "A permanent redirection for this resource"
  • Click on 'Apply'

ColdFusion Redirect

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="">

PHP Redirect

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location:" );

ASP Redirect

<%@ Language=VBScript %>
Response.Status="301 Moved Permanently"
Response.AddHeader "Location",""

ASP .NET Redirect

JSP (Java) Redirect

response.setHeader( "Location", "" );
response.setHeader( "Connection", "close" );

CGI PERL Redirect

$q = new CGI;
print $q->redirect("");

Ruby on Rails Redirect

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to ""

HTML Redirect

The HTML redirect allows to introduce a delay before the redirection is performed. It is sometimes called “META refresh” redirect.

Browsers will display the page during the specified time and then move forward to the page pointed to by the redirection.

HTML Redirect Source Code


Seconds: the number of seconds the page is displayed, before performing the redirection.

the-other-url : any absolute or relative URL that will be displayed after the delay has expired.

It is recommended that a standard link be added in the page for the few users of browsers that do not automatically follow redirections.

Examples of HTML Redirects

<META HTTP-EQUIV="refresh" CONTENT="5;URL=the-other-page.html">
The redirecting page will be displayed during 5 seconds. After this 5 seconds delay, it will be replaced by “the-other-page.html”.

The redirecting page will be displayed during 12 seconds. After this 12 seconds delay, it will be replaced by the home page of this site.

<META HTTP-EQUIV="refresh" CONTENT="0;URL=another-page.html">
The redirecting page will be displayed and immediately replaced by “another-page.html”. With this zero-delay, many users will not even notice the presence of the redirecting page.

Term Papers said...

I have been visiting various blogs for my term papers writing research. I have found your blog to be quite useful. Keep updating your blog with valuable information... Regards

Ginger Sanches said...

Your blog is very informative and the info is really cool. Wait for your new articles. Come here to get new paper editing service
Be successful!

Post a Comment

Kishore SEO - Latest SEO Updates and Online SEO Training ©2008.


Item Reviewed: Description: Rating: 5 Reviewed By: