SGIS news

Force www in URL

We’ve put this quick guide together as we have had a number of request recently on how to force www to the URL. For example, if someone enters yourdomain.com they will be redirected to www.yourdomain.com. This is important as it avoids search engines indexing duplicate content for your website as the same content could be listed both on yourdomain.com and www.yourdomain.com.

Some CMSs, such as WordPress, take care of this for you but if you’re CMS or website doesn’t do this as standard we have included instructions and code below to force www.

1. Open the public_html folder on your hosting account.
If you already have a .htaccess file in the public_html folder please open it and go to step 3 – please make sure to backup your .htaccess file before attempting any changes.

2. Click on the create new file button and enter .htaccess as the file name.

new-file
 
3. Paste the below code into the text area and hit save.

# Turn on the Rewrite Engine
RewriteEngine On
RewriteBase /

# Force www
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

htaccess

N.B. Please remember to replace yourdomain.com with your actual web address.

4. Test the change by entering yourdomain.com into your web browser and you will be redirect to www.yourdomain.com.

If you have any questions please contact support.