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

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

Place this code in your .htaccess file and Save the .htaccess file and Upload this file to the root folder of your server.

If you want to redirect old page name to new page name. Do following.

Redirect 301 /oldpage.html http://www.you.com/newpage.html

Other ways to implement the 301 Redirect:

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

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

Redirect Domain with WWW.

If you need to redirect http://example.com to http://www.example.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 you can use this one too:

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

——

Follow HNW on TwitterTwitter, Become a fan on FacebookFacebook and Subscribe to RSSRSS.

Popularity: 8% [?]

No related posts.


Do you like this story?

6 Responses to “How to Use 301 .htaccess Redirect?”

  1. kmadhav
    On August 9th, 2010

    yes…this information is I am searching on the web …content is very easy to understand …Keep it up!! good work

  2. Sunil Singh
    On August 30th, 2010

    Very cool! details on the how to do redirects with various options thanks.

  3. Themarabot
    On September 8th, 2010

    I’ve made my first CSS 3 – HTML 5 websites and i love it! We can make a border radius, no need anymore to do it in Photoshop!

  4. Utah SEO
    On September 9th, 2010

    1 of the very most useful pieces of important information I offer to valued clients is concerning web-site usability. You will discover so many specialists out there trying to get ranked, but their web sites tend to be crappy. You need to make many changes to get ranked and stay ranked.

  5. Kiby
    On September 10th, 2010

    This is a really good read for me. Must admit that you are one of the coolest bloggers I ever saw. Thanks for posting this informative article.

  6. Sarah Farrukh
    On January 19th, 2011

    very nice info….

Leave a Reply: