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 instead of 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 text in it. Just add www to them (as example and save files.

opencart add www in url

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

Related OpenCart extensions