My OpenCart is installed in a '/shop' directory and I'm having a problem using this code below:
RewriteBase /shop
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Problems I'm seeing:
1.) When I type my domain without WWW, it doesn't redirect to my domain with WWW.
2.) When I type my domain without WWW, but also include the '/shop' directory to access the OCart, it redirects back to
http://www.mydomain.com without the '/shop' directory.
Thanks for the help.
*******EDITED*********
I just figured out solution for #2 above:
When I change
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] to
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/shop$1 [R=301,L] (adding the /shop) it correctly redirects when typing the /shop directory.
Still can't figure out how to solve #1 though. Help on that appreciated.