Adding 301 Redirects using htaccess
It’s easy adding 301 redirects to your website using Apache’s htaccess. A 301 redirect is the most efficient and Search Engine Friendly method for web page redirection. It’s not difficult to implement and will preserve your search engine rankings as well.
Often when someone does a redesign of their website or puts it into a new platform, and little consideration is regarded for the difference between the existing an new link structure. You should have a redirect in place if your old link structure varies from the new one. This will help you maintain you search engine rankings and decrease the possibility if someone reaching a 404 page.
Below is one variant of a 301 that redirects when someone tries to access your website without the (www); It will redirect the URL to your website with the www. You should choose which variation your website should stick with because accessing your website both ways is bad for Search Engine Optimization.
So, to implement this type of redirect for your website, follow these instructions:
- Open up notepad or any other text editor and copy and paste the commands below.
- Change (yourdomain) to your domain name.
- Save the file with this name: (.htaccess). There is no file name. If you have a problem doing this on Windows, read this article.
- Upload it to the root directory of your website.
1 2 3 4 |
Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] |
This was so incredibly helpful! Thank you for sharing this!
Awesome!
This was a pretty good post
Thanks!