Adding a 301 permanent redirect using htaccess

It’s easy to add 301 redirects to your website using Apache’s htaccess. A 301 permanent redirect is the most efficient and Search Engine Friendly method for web page redirection. It’s not difficult to implement and, if done appropriately, it will improve your search engine ranking as well.

A simple use of a 301 permanent redirection is to redirect yourdomain.name to www.yourdomain.name. So when someone tries to access your website without the www, it will redirect the URL to your website with the www. This practice avoids the duplication of URL’s for the same web page – making your website much more friendly for search engines. It will also ensure that all your site’s inbound links will be counted towards the same website – and not divided into www.yourdomain.name and yourdomain.name.

To implement this for your website follow these instructions:

1. Open up notepad or any other text editor and copy and paste the commands below.
2. Change (yourdomain) to your domain name.
3. Save the file with this name: (.htaccess). There is no file name.
4. Upload it to the root directory of your website.

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

4 Comments

  • Reader
    Great! Thank you!
    I always wanted to write in my site something like that. Can I take part of your post to my site?
    Of course, I will add backlink?

    Regards, Timur Alhimenkov

  • Richard
    Sure you can! A link back would be appreciated. I’m happy you enjoyed the post. Check back frequently as we update our Web Design Blog often.
  • Ben
    This is great – the most simple 301 redirect solution I’ve found so far.
  • anioly
    I’m under the impression that this is one of the best blogs ever.

Leave a Reply

Sorry - this blog is now closed to new comments.