Post by todavy » Thu Jun 19, 2014 2:10 am

Opencart version: 1.5.6.4

The Add-to-cart-buttons on the products on the first page (Featured group or Special group) does not work when using this URL: http://www.example.com/webshop but they work when using http://example.com/webshop.

I understand the problem is in the .htaccess file but I don't know how to change it so the redirect works. Pasting the content of the file below. By the way. The following line makes no sense to me:

Code: Select all

# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

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 "\.(tpl|ini|log)">
 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 /webshop
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^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
Last edited by todavy on Mon Jun 23, 2014 6:47 pm, edited 2 times in total.

Newbie

Posts

Joined
Tue Jun 10, 2014 5:00 pm

Post by tacobandito » Thu Jun 19, 2014 2:20 am

First thing would be to change

Code: Select all

RewriteBase /webshop
to
RewriteBase /webshop/
other than that, you can add the below code to redirect www to non-www

Code: Select all

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

[module] PayPal Pro w/Recurring Profiles FREE
[module] 1 Click "Amazon Style" Checkout w/PayPal Pro FREE
[module] Adjustable PayPal Pro Fee FREE
[module] Add Sample To Cart LITE FREE
The guide to fixing just about everything wrong with OpenCart FREE!
Add INFINITE SCROLL to your homepage for FREE!
Live update product price for FREE!
Dynamic generation of Opencart coupon, FREE!
Hire me


User avatar
Active Member

Posts

Joined
Sat Mar 30, 2013 12:27 am
Location - Springfield, MA

Post by todavy » Thu Jun 19, 2014 3:15 am

Thanks for reply. Maybe that works too.

I just found this solution by adding this code in the .htaccess

Code: Select all

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
..just below this code

Code: Select all

# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 
RewriteBase /webshop
Update: Not solved.. Only works in Google Chrome. When opening the site in Internet Explorer it redirects back to the domain root when using both urls... What has .htaccess to do with the webbrowser???

Newbie

Posts

Joined
Tue Jun 10, 2014 5:00 pm

Post by todavy » Thu Jun 19, 2014 4:10 am

Now I'm trying tacobandito's solution but it doesn't seems to be some cache that make the changes not work direct... Why does .htaccess code work in Chrome but not IE anyway?

Newbie

Posts

Joined
Tue Jun 10, 2014 5:00 pm

User avatar
Active Member

Posts

Joined
Sat Mar 30, 2013 12:27 am
Location - Springfield, MA

Post by todavy » Thu Jun 19, 2014 5:52 am

Problem solved! ..again! Now it works in IE too, after trying "In Private mode". But clearing the cash 10 times and restarting the browser didn't do it alone!!! Isn't this the way to clear cache in IE??? Tools - Internet options - Delete - Mark all options but Form Data and Password and click delete?

So this is the cure:

Code: Select all

RewriteBase /webshop/
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
Not sure wether it should be RewriteBase /webshop/ or RewriteBase /webshop (one slash only). I see different versions on the net. Maybe it doesn't matter.

Newbie

Posts

Joined
Tue Jun 10, 2014 5:00 pm

User avatar
Active Member

Posts

Joined
Sat Mar 30, 2013 12:27 am
Location - Springfield, MA

Post by STN » Thu Jun 19, 2014 6:02 am

Hey,

You need to put a trailing slash after
RewriteBase /webshop

to

RewriteBase /webshop/

Its in the comments as well in htaccess files.

Clear your browser cache because redirects sometimes don't work instantly in browser.

Cheers
todavy wrote:Opencart version: 1.5.6.4

The Add-to-cart-buttons on the products on the first page (Featured group or Special group) does not work when using this URL: http://www.example.com/webshop but they work when using http://example.com/webshop.

I understand the problem is in the .htaccess file but I don't know how to change it so the redirect works. Pasting the content of the file below. By the way. The following line makes no sense to me:

Code: Select all

# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

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 "\.(tpl|ini|log)">
 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 /webshop
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^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

Game Trainers


STN
New member

Posts

Joined
Fri Jul 01, 2011 6:45 am


Post by todavy » Fri Jun 20, 2014 9:32 pm

Just a newbie kind of question.. How do I mark the topic [Solved]?

Newbie

Posts

Joined
Tue Jun 10, 2014 5:00 pm

Post by todavy » Mon Jun 23, 2014 6:47 pm

Hmmm....

Newbie

Posts

Joined
Tue Jun 10, 2014 5:00 pm
Who is online

Users browsing this forum: No registered users and 20 guests