Post by jdiai » Wed Jan 01, 2014 11:37 pm

i was having a problem similar to this. i tried to do a .htaccess redirect on my site from non www to www version. my original .htaccess file looked like this

# SEO URL Settings
RewriteEngine On
RewriteBase /
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]

so what i did was i edited it to this

RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
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]

this worked in redirecting my url from non www to www. but i later noticed that my add to cart feature wasnt working. so i also had to edit my config.php files in both public_html and admin folder to www version. that is editing my site url from non www to www in config.php folders. hope this helped

Newbie

Posts

Joined
Tue Nov 12, 2013 11:30 pm

Post by maricor » Wed Apr 30, 2014 4:17 pm

i have same problem here.
i want to redirect domain.com to www.domain.com
i use this code:
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

I can redirect the page to www.domain.com but i cannot login to admin panel
please help me..

Newbie

Posts

Joined
Fri Nov 30, 2012 9:57 am

Post by opencartdamir » Sat Oct 11, 2014 6:33 pm

I saw that this post is highly ranked on Google and yet it does not have appropriate answer to www issue.

So I managed to redirect my OC site from non-www to www and still I am able to login to my admin panel.

1. to .htaccess file add this piece of code if you want to redirect from non-www to www:

# Begin Redirect 301
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
# BEGIN OpenCart
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END OpenCart

PS replace domain.com with your domain and TLD.

2. Go to admin/config.php and under define HTTP_SERVER add www to your domain
3. Go to config.php in root folder and also add www to your domain under define HTTP_SERVER
4. If you installed with Softaculous Auto Installer then go to your hosting control panel under Softaculous, locate OpenCart, click Edit and change domain.com -----> www.domain.com

VOILA :) Now you have www open cart site with fully functional Admin panel and no duplicate content :)

Newbie

Posts

Joined
Sat Oct 11, 2014 6:24 pm

Post by fsoft » Sat Jan 24, 2015 10:23 pm

hello,

i have eshop on OpenCart 1.5.6.4 (http://svetposteli.com) and I have problem with redicert from www to non www.
I have in .htaccess this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)
RewriteRule (.+) http://%1/$1 [R=301,QSA,L]

but it works only when i click for example from: http://www.svetposteli.com/postel-z-masivu-nyja-typ-101 it right redicert to http://svetposteli.com/postel-z-masivu-nyja-typ-101 but when i click to http://www.svetposteli.com nothing happens -
does not redirect me to and i´m still at http://www.svetposteli.com

can you please me help with this issue?

Thanks

Paul

http://svetposteli.com


Active Member

Posts

Joined
Sun Dec 29, 2013 9:06 pm

Post by foxwizzy » Sun Oct 23, 2016 2:22 am

Hello forum
i am haveing the same problem.....i have tryed all that i read in this topic and its not working for me.....
this is how my .htaccess.txt looks

Code: Select all

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# 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 /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www .%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/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]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none
the root config.php and admin config.php is with www

can anyone help me please
thankyou

Newbie

Posts

Joined
Sun Oct 23, 2016 2:19 am
Who is online

Users browsing this forum: No registered users and 399 guests