Start a conversation

Search Engines Optimization Tweak to htaccess file

Problem:

It is an important SEO issue because the SEs can view the www and non-www as 2 SEPARATE sites with identical content... and with the big deal the SEs are stressing right now w/duplicate content, no one wants their site to be penalized.

The results from testing should be the SAME destination URL in the address bar - no matter what someone types in. These instructions use the www as the destination - which is fine (the destination can be either the www or non-www)

Solution:

It involves creating a .htaccess file, or editing one that already exists in
the hosting account's files. The file should be in the highest level,
publicly accessible folder (usually called www/, htdocs/, or public_html/).
If the file already exists on the server in one of those directories,
download it onto your computer using an FTP program. If there isn't a file
there, you'll need to create one.
*
* *To create an .htaccess file:*-Open up Notepad
-Copy and paste the following into the file:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www.domain-name.com [NC]
RewriteRule (.*) http://www.domain-name.com/$1 [R=301,L]

-*Replace "domain-name"* with the name of the domain. Replace "com" with the
appropriate extension (like "net") if necessary.
-Do File > Save As. In "File Name:", type "*.htaccess*", then choose "*Save
as Type: All Files*". Click Save.

--------------------
*To edit an existing .htaccess file (make sure that you make a backup of the
file before doing this):*-Open up Notepad
-Do File > Open and browse to the location of the .htaccess file you
downloaded onto your computer. In "*Files of Type:*" select "*All Files*",
and the .htaccess file should become visible in the file list.
-Check for the following, but do not replace or add this code if it's
already in the file. *If it's not there, add it.*

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

-*Add the following:*

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www.domain-name.com [NC]
RewriteRule (.*) http://www.domain-name.com/$1 [R=301,L]

-*Replace "domain-name"* with the name of the domain. Replace "com" with the
appropriate extension (like "net") if necessary
-Save the file.

----------------------

*After you're done*, put the file on the server using your FTP program. Make
sure that you put it in the highest level, publicly accessible folder
(usually called www/, htdocs/, or public_html/). After that, *check the
website* to make sure that everything is functioning properly.

*If you receive an error* like the one below, then something is wrong with
the .htaccess file, and you'll need to check it over to make sure that you
followed the steps above properly.

*500 Internal Server Error

The server encountered an unexpected condition which prevented it from
fulfilling the request.

*If you continue receiving the error after you've corrected the file (or if
you didn't have to), remove the .htaccess file from the server and/or revert
back to the backup file that you made (To revert, put the backup on the
server. Make sure that it's named ".htaccess").
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Admin FinestShops

  2. Posted
  3. Updated

Comments