Knowledgebase

KnowledgebaseCloud/VPSCloud HostingFile Management
Back to File Management

How To Force WWW For SEO


This article is for cPanel Accounts. Determine where your account is with this guide.

By default, search engines such as Google consider www.domain.com and domain.com as separate, independent websites. The same is true for different domain names -- Google treats example.com and example.net as completely separate, independent websites, even if they both show identical content.

Multiple websites showing the same duplicate content can be penalized with lower search engine rankings. To solve this problem, you can -- and should -- force your website to operate under a single web address (for example, always show www.domain.com) by adding code to the .htaccess file inside the domain's web root directory.

It is not important which domain name you choose as the "preferred" name -- whether to always or never use the "www" portion -- as long as you choose so search engines treat all versions of the website address the same.

For your default domain name, you would create or edit the file public_html/.htaccess and add the code below to the top of the file. Replace www.domain.com with your domain name.

Code:

# Force a preferred domain name for SEO
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

Changes to .htaccess files are always immediate, although you may need to clear your web browser's cache to make sure you're getting the latest information from the web. After making the change, type the "wrong" version of the address into your web browser and it should be corrected for you automatically.


Related Articles

Am I Responsible For Monitoring My Bandwidth Usage
Can I Add My Own CGI Scripts
Can I Point My Primary Domain To A Sub-folder
Can I Reset My Website Files
Can I Use A .htpasswd File In My Account

Can’t Find what you need?

No worries, Our experts are here to help.