Improve your search engine rankings with .htaccess

Search engines like Google see and as two completely different sites and that can lead to duplicate content penalties and lower rankings. What can be done to correct this issue? Amazingly it is just a few lines of code in your .htaccess file.

On we use the following code:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.buyhttp\.com
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*)$1 [R=301,L]

Let’s go through that line-by-line to examine what’s happening.

RewriteCond %{HTTP_HOST} !^www\.buyhttp\.com

This line says if the host URL doesn’t start with execute the following code. It is important to have the \ before each .

RewriteCond %{SERVER_PORT} !^443$

This line says if the request isn’t made on port 443 (used for SSL or https://) execute the following code

RewriteRule (.*)$1 [R=301,L]

This is the meat of the rule. It tells the server to take all of the URL after the .com/ and put it after and do it as a 301 (permanently moved) redirect.

The overall rules state that if a request comes in without the www. and it’s not over a secure connection rewrite it to contain the www.

If you are adding this to an existing .htaccess file for a system like Mambo or Joomla with SEF URLs the placement is very important. It must be after RewriteEngine On in your existing file and before the core SEF rewrite rules. You will also want to make sure you only have one instance of RewriteEngine On in the file.

Taking a few minutes to implement these few lines of code will not only help with your search engine rankings but will also result in uniform URLs throughout your site.

Buyhttp servers runs on Enterprise Class High End DELL Servers, get started for $1

Leave a Reply

Your email address will not be published. Required fields are marked *