Adding a 301 permanent redirect using htaccess
- Category: web design, web development
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]
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