Last Updated on September 21, 2023 by Christopher G Mendla
Before you begin, be aware that errors in your .htaccess file could result in an unreachable site or loss of traffic.
It is important to ensure that search engines do not see duplicate content on your site. This can result in a penalty or dilution of your traffic. One of the more common errors is to not redirect your example.com traffic to www.example.com or vice versa. In other words, the search engines begin to believe you have two identical sites.
One site that will tell you if you have this problem is http://www.pearanalytics.com/ . You simply enter your site’s address and it will provide some basic, but important SEO information.
If your site is hosted on an Apache server, you can fix this with a few simple lines in your .htaccess file. If you are running Joomla, you should have an active .htaccess file anyway.
To do this, you should
- Back up your existing .htaccess file. You should already be familiar with the .htaccess file and editing files using an FTP client such as Filezilla.
- Open the .htaccess file for editing.
- If you are using Joomla and the .htaccess file provided by the Joomla installation, you should see an area about redirecting non www pages to the www.pages.
- Post the code below in AND modify it to reflect your site name.
RewriteEngine OnRewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]
- NOTE – you only have to have the RewriteEngine On line once.
- Now TEST your site including any administrative back ends.
http://www.pearanalytics.com/blog/2010/implementing-a-proper-301-redirect-on-apache-or-windows-servers/