Tommy Logic™

  • Increase font size
  • Default font size
  • Decrease font size
Home Tutorials Web Design How to Redirect a Web Page | 301 redirect

How to Redirect a Web Page | 301 redirect

E-mail Print
Article Index
How to Redirect a Web Page | 301 redirect
redirect-single-page
All Pages
Why would you do this? Here are a couple of the main reasons:
  • Users may access your page from both "www.yourdomain.com" AND "yourdomain.com" {search engines penalize your page ranking by splitting the ranks of the two}
  • You have moved a page permanently. Well, users may have bookmarked a page in your site that no longer exists.
  • You have links to a non-existing web page that you have posted on another site.

I'll list three of the best methods for getting a web page to redirect to another page.

Note: be sure to save a copy of your current ".htaccess" file as a backup in case you're server has issues with this tutorial.

 

If you have "permanently" moved a page on your site then it is best to tell the server and everyone else it has too. The best method to accomplish this known as the "301 redirect". This will tell the web browser (or more importantly the search engines) that this page has been moved to its new location. The "301" does it as soon as the page is triggered.

Redirect All Pages

When a user types in  http://your-domain.com , They will automatically be redirected to  http://www.your-domain.com

mod_rewrite {my favorite method}

  1. Create or open a file called .htaccess in the root directory of your website.
  2. Open .htaccess using your favorite text editor.
  3. Copy and paste this code below into your file, exactly as it appears replacing your-domain.com with your domain.
    **Note** if .htaccess already exists, you can usually append this to it.
    Code:
    #  mod_rewrite in use

    RewriteEngine On

    ######## BEGIN www Search Engine Redirect
    # Rewrites url http://your-domain.com
    # as http://www.your-domain.com
    # this prevents search engines from splitting your ranks
    # on the two

    rewritecond %{http_host} ^your-domain.com
    rewriteRule ^(.*) http://www.your-domain.com/$1 [R=301,L]

    ####### END Search Engine Redirect
  4. Save .htaccess to the root directory of your website {usually where your main homepage is located}



 

Bookmark This

Featured Tools

Authorized Adobe Reseller

Adsense Links


Newsflash

Freelance | Ad Hoc Services
On a budget or due tomorrow? We may be able to assist you with your creative needs. Tommy Logic has a staff of professionals who are eager and more than capable of handling your project... and we can do it in a timely manner.