Post by vaidyamanishjoshi » Thu Jul 12, 2018 9:40 pm

I am using opencart 3.0.2.0

My store is installed in a folder. e.g. www.myrootdomain.com/eshop

In my root domain htaccess, I have added following code to force www and to force https, But it is not working for /eshop

e.g.
if user types myrootdomain.com, he get redirected to https://www.myrootdomain.com

but if he types url for shop directly like myrootdomain.com/eshop, he is expected to redirect https://www.myrootdomain.com/eshop
but it is not working


code in htaccess in root folder is as follow :

Code: Select all

RewriteEngine on
#Force www:

RewriteCond %{HTTP_HOST} ^myrootdomain.com [NC]
RewriteRule ^(.*)$ https://www.myrootdomain.com/$1 [L,R=301,NC]

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.myrootdomain\.com$ [NC]
RewriteRule ^(.*)$ https://www.myrootdomain.com/$1 [L,R=301]

Active Member

Posts

Joined
Tue Jun 09, 2015 2:47 am

Post by Qphoria » Thu Jul 12, 2018 10:05 pm

I use this

Code: Select all

RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
You can just use it as is on any site because you don't need to hardcode the actual domain name. HTTP_HOST is a variable.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: Majestic-12 [Bot] and 26 guests