This article describes how to add or remove the www prefix in your domain's URLs. For example, if users type www.example.com in their browsers, you can automatically redirect them to example.com, or vice versa.
For Search Engine Optimization (SEO) purposes, it is preferable to have a website respond only to http://www.example.com or http://example.com, not both. Otherwise, search engines see duplicate content on the www and non-www domains, and may downgrade the site ranking.
You can automatically add the www prefix to your domain's URLs by using Apache rewrite rules in a custom .htaccess file. To do this, follow these steps:
# Add www to any URLs that do not have them: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
You can automatically remove the www prefix from your domain's URLs by using Apache rewrite rules in a custom .htaccess file. To do this, follow these steps:
# Remove www from any URLs that have them: RewriteEngine on RewriteCond %{HTTP_HOST} ^www\. RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.