Post by dsb802 » Mon Feb 12, 2018 2:35 pm

Hi,
I've installed WordPress in main directory of my site and OpenCart in sub-folder of my site /shop/
Now I want to redirect non www to with www
My main site URL is https://www.gethappythoughts.org/
Opencart URL is - https://www.gethappythoughts.org/shop/

I've tried adding several codes in OpenCart .htaccess and WordPress .htaccess to make it possible but not able to achieve it.
Please help me
Config - URL in my shop/config file and shop/admin/config file is with www
OpenCart .htaccess:

Code: Select all

RewriteEngine On
RewriteBase /shop/
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) 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]
I've tried below in OpenCart .htaccess but it is not working:

Code: Select all

RewriteCond %{HTTP_HOST} ^gethappythoughts.org/shop/$
RewriteRule (.*) http://www.gethappythoughts.org/shop/$1 [R=301,L] 
Issue with the following code is if anyone accesses my shop without www then it redirects visitors to the main site

Code: Select all

# Redirect non-www urls to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Please help

Newbie

Posts

Joined
Fri Mar 02, 2012 3:25 pm
Who is online

Users browsing this forum: E@gle2313, Google [Bot], guiadeempresas, karlopencart and 13 guests