How to add www resolve to OpenCart for better SEO

How to add www resolve to OpenCart for better SEO

If you just installed a fresh OpenCart shopping cart system to your host you probably noticed that your store address does not contain www symbols in it – for example url is http://your.store instead of http://www.your.store. It may not be a big deal – your store will work just fine, but redirecting store to www does have some benefits – at least for search engines which love to see websites in that way. So how to solve it?

How to redirect OpenCart store to www url (OpenCart www)

You need 3 simple steps to make www appear in url:

Enable .htaccess file in FTP. When you install OpenCart this file is in the root FTP folder (usually it’s public_html/), and it’s sort-of disabled – named as .htaccess.txt . You need to rename it – just remove the .txt part , so it will become .htaccess file and will be active then.

opencart htaccess file

Open .htaccess file in text editor, and look for these lines:
# SEO URL Settings
RewriteEngine On

After the second line add another 2 lines of code:
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Then save the file.

opencart www

There are two config.php files in your OpenCart store – one in root directory (the same as .htaccess file), and another in admin/ folder. Open them both in text editor, and look for http://your.store text in it. Just add www to them (as example http://www.your.store) and save files.

opencart add www in url

That’s it – your store now will be redirected from http://your.store to http://www.your.store in every single page automatically.

Related OpenCart extensions