Page 1 of 1

non www and non https to https://www

Posted: Sun Dec 30, 2012 12:41 am
by growlbox
I wanted to share my .htacces code for the people who would like to use an ssl.

First off, be sure to enable SSL in the admin area, Config -> Store-settings -> Server

Edit your .htaccess file ( in root folder );
  • RewriteBase /opencartsubfoler

    RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
    RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]

    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www.opencartsite.com/opencartsubfoler/ [R]
The first line needs to be set if you're oc install is in a subfolder of root. in this case root/opencartsubfollder/
If OC is in your root folder leave the / so that the line looks like this --> "RewriteBase /"

Ignore line 2 to line 7.

RewriteCond %{HTTPS} off // Checks if the url has https:// if not then do...
RewriteRule (.*) https://www.opencartsite.com/opencartsubfoler/ [R]


What this does it redirects all non www (http://opencartsite.com/opencartsubfoler/) and www (http://www.opencartsite.com/opencartsubfoler/) to https://www.opencartsite.com/opencartsubfoler/





The only thing it doesn't do is redirect https://opencartsite.com/opencartsubfoler/ to https://www.opencartsite.com/opencartsubfoler/

Has anyone got an idea? I'm open for any critical suggestions or alternative solutions!

Re: non www and non https to https://www

Posted: Tue Jan 01, 2013 11:45 pm
by victorj
this can be done without .htaccess.

in config.php root and admin change all urls (change http to https) at beginning of file to:
https://www.opencartsite.com/opencartsubfoler/

opencart does the rewrite correctly.