How to set a 301 redirect

You've just redesigned some pages of your web site. The pages have high search engine rankings that you don't want to lose. How can you safely redirect web site traffic from your old pages to the new pages without losing your rankings? You can do this by using a " 301 redirect " So , What actually is this “301” ?

A 301 redirect allows visitors and search engines to access a web page after it has been moved. If you have changed the domain name of your web site or changed the file names of pages, then you need to link to the new URLs for visitors and search engine spiders. The 301 permanent redirect is the most search engine-friendly method of redirection to the new URL or page and is the current standard for SEO purposes.

You can use it in several situations, including:
·         to redirect an old website to a new address
·         to setup several domains pointing to one website
·         to enforce only one version of your website (www. or no-www)
·         to harmonize a URL structure change

PHP Single Page Redirect

In order to redirect a static page to a new address simply enter the code below inside the index.php file.
header("HTTP/1.1 301 Moved Permanently");

PHP Canonical Redirect

The Canonical 301 Redirect will add (or remove) the www. prefixes to all the pages inside your domain.
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$_SERVER['HTTP_HOST']
Apache .htaccess redirect

 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

ASP .NET Redirect :
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";

Canonical Redirect using IIS 7.0

For this to work, you need to download and enable the URL Rewrite module for IIS 7. Then the following code is used in the ASP.NET web.config file:
        <rule name="Redirect to WWW" stopProcessing="true">
          <match url=".*" />
            <add input="{HTTP_HOST}" pattern="^$" />
          <action type="Redirect" url="{R:0}"

               redirectType="Permanent" />


nice post gonna do the same for my blog too... :)

As soon as when a time, college students were actually obligated to perform all the things themselves.

Post a Comment


Free Hit Counters

Review this blog on