InMotion Hosting Support Center

Redirect my OpenCart site from non-www version to the www version

Category: Opencart

2014-05-16 2:29 pm EST

Hits: 1,809
I would like to redirect my OpenCart site from the non-www version to the www version.

Here is what my .htaccess file looks like now:

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Any help is much appreciated, thanks in advance


You must login before you can ask a follow up question.

You must login before you can submit an answer.



9,968 Points
2014-05-16 2:51 pm EST
Hey ArkenSeal, and thanks for the great question.

We actually have a guide on <a href="" target="_blank">force the www version of a domain</a> which in your case would end up looking like this part highlighted in <span style="color: red;">red</span>:

<pre class="code_block" style="margin: -10px 0px -30px 0px; line-height: .9em; padding: 15px 0px 15px 5px;"># SEO URL Settings
RewriteEngine On
<span style="color: red;">RewriteCond %{HTTP_HOST} ^ [NC]</span>
<span style="color: red;">RewriteRule ^(.*)$$1 [L,R=301,NC]</span></pre>

Of course you'll want to replace <span style="color: red;"></span> with your own domain name for it to work properly.

Let us know if that does the trick for you, and if you have any other questions at all!

- Jacob

You must login before you can post a comment about this answer.

Hello Jacob, and thank you for your prompt response and for your help.
I have successfully redirected my domain to the www version. However, as I was unable to log in to my administration panel, I have contacted the community-support . They advised me to update my config.php file which i did and everything went perfect.
Once again thank you very much for your help.
87 Points
2014-05-19 2:10 pm EST
Like this Question?

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!