Post by Superior1 » Sun Dec 11, 2011 8:06 pm

Hello

My site currently has duplicate pages as /index.php is also present as another version of the home page etc. Also, the site is accessible without www.

So, to rectify the above I added the below code to the htaccess.txt file:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.co\.uk
RewriteRule (.*) http://www.mydomain.co.uk/$1 [R=301,L]
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.mydomain.co.uk/$1 [R=301,L]
In order to then make this work, I had to change 'htaccess.txt' to just 'htaccess' however as soon as I did this two errors occurred:

1. I can no longer access my admin area
2. add to cart stops working on the website (you click it and nothing happens).

This problem has also occurred when I try to activate SEO URL's in the admin area, in order to do that I also have to change htaccess.

Any advice very much appreciated.

Cheers
Last edited by straightlight on Wed Aug 10, 2016 9:51 am, edited 2 times in total.
Reason: Added quote tags.

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by uksitebuilder » Mon Dec 12, 2011 5:09 am

There should be a logical order to the .htaccess, you cannot just put rules and symlinks anywhere

replace your htaccess content with the following:

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

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Superior1 » Mon Dec 12, 2011 10:12 pm

Hi UKSB

Thanks for the help, much appreciated. I just did as you suggested but the same problem occurred plus the front end stopped working if I didn't include the www. I'm pretty sure I'm doing something wrong! I copied your code exactly, and then I tried messing with the below element:
uksitebuilder wrote: RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
[/code]
I put my domain in various places to try and get this working. I'm quite a novice in coding so apologies in advance if I'm missing something that should be obvious.

If it's of any use, I also have a shared SSL set up so not sure if this is having any negative effect.

Many thanks

Chris

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by uksitebuilder » Tue Dec 13, 2011 12:16 am

Shared SSl doesn't work with OpenCart out of the box.

In your config.php and admin/config.php you should have your main domain (not the SSL) set in the HTTP defines

Your SSL should only be set in the HTTPS defines.

However as mentioned above, shared SSL simply doesn't work with OC by default without an extension

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Superior1 » Tue Dec 13, 2011 5:17 am

Hi there

Yes, I bought the extension from yourselves (UKSB-Shared-SSL-Support-v-1.0.0).

As that extension is installed, is there any other potential cause of the issue?

Many thanks for your help.

Chris

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by uksitebuilder » Tue Dec 13, 2011 3:31 pm

Is there a link I can view

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by uksitebuilder » Tue Dec 13, 2011 6:33 pm

comment our the RewriteBase / line

like so

# RewriteBase /

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Superior1 » Wed Dec 14, 2011 6:49 am

uksitebuilder wrote:comment our the RewriteBase / line

like so

# RewriteBase /
Hi Simon

Ok have done this, now what's happening is if I enter mydomain.co.uk it redirects to http://www.mydomain.co.uk which is great.

However three issues remain:

1. /index.php doesn't redirect to http://www.mydomain.co.uk
2. Same as point 2 when I click checkout on the site

I've changed the htaccess back to .txt for now.

Hope you can help? Not sure what link I could send that may help so let me know?

Many thanks

Chris
Last edited by Superior1 on Fri Jan 20, 2012 6:28 am, edited 1 time in total.

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by Superior1 » Wed Dec 14, 2011 7:05 am

Something else has happened now, unsure if related but I haven't altered anything else:

The add to cart button in category has started to go to a product not found page, instead of adding straight to the basket as it did previously. For example:

http://www.mydomain.co.uk/index.php?rou ... path=17_85

I have put the old content back into htaccess and changed it back to .txt so I can't see how this has been affected - although I did have this problem briefly after I set up the shared SSL as per the readme file with the download (seemed to rectify itself though??

Sorry, feel like I'm being a pain in the ass..

Many thanks
Last edited by Superior1 on Fri Jan 20, 2012 6:29 am, edited 1 time in total.

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by uksitebuilder » Wed Dec 14, 2011 11:06 pm

something appear to be swapping your & signs to & in the URL which is why you are getting product not found.

I see you are on 1.5.0 - Is that 1.5.0.5 ? If not, I would seriously suggest upgrading to 1.5.0.5 at the least to remove any bugs.

I seem to remember a bug fix related to ampersands in URLS which may resolve your issue.

back to the htaccess problem.

We need to put a condition in the htaccess for the SSL because that is not on www. so we need to tell it not to rewrite to www. for SSL addresses.

The index.php and index.php?route=common/home both need to be redirected to just the domain name.

Please see amended htaccess code below which should hopfully fill all of that.

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 /
RewriteCond %{HTTP_HOST} ^superiorbedlinen\.co\.uk
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule .? http://www.%{HTTP_HOST}/? [L,R=301]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.%{HTTP_HOST}/? [L,R=301]
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
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

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Superior1 » Thu Dec 15, 2011 7:20 am

Hi Simon

Thanks for this, I will sort the upgrade, one question on that as I haven't upgraded before - I've edited a fair bit for example losing things like refine search, reward points etc. When I upgrade will these all reappear and have to be edited again?

And back to this htaccess issue, thank you for the new content. I put this in place and the SSL matter resolves. However it was taking me to the home page whatever I clicked and also made the domain http://www.www.superior..... So two lots of www?

I messed with this element a bit and have stopped that happening as follows:

Code: Select all

#RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.co\.uk
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
This makes the none www version redirect to www but index.php is still present as a duplicate.

Again, any advice very much appreciated....

Thanks

Chris
Last edited by straightlight on Wed Aug 10, 2016 9:52 am, edited 2 times in total.
Reason: Added code tags.

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by Superior1 » Mon Dec 19, 2011 7:35 am

Sorted it, as follows:

Code: Select all

#RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.co\.uk
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.mydomain.co.uk/ [R=301,L] 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Thanks for all your help. I still have 'Add to Cart' error but will have to upgrade.

Cheers

Chris
Last edited by straightlight on Wed Aug 10, 2016 9:52 am, edited 2 times in total.
Reason: Added code tags.

New member

Posts

Joined
Sat Aug 27, 2011 5:39 pm

Post by rmarques » Wed Dec 21, 2011 7:28 pm

I'm having a problem with customer and admin login only on Firefox. Admin and customer login work just fine on IE and Chrome. On firefox I'm getting 400 bad request because it's trying to redirect the login url to .www.www and firefox does not understand it.

The login process is being done, it just doesn't take the user to the intended page, the page gets stuck. This problem is happening to me with SEO enabled/disabled, with .htaccess or without .htaccess, it doesn't matter.

As for admin login I'm using Chrome to manage the store, the problem is for customer login, many people use firefox and they will have problems.

If anyone knows a solution for this problem, please help. Thanks!

I'm using the latest firefox version and opencart 1.5.1.3

http://www.chimarrao.com/loja/

Newbie

Posts

Joined
Fri Sep 10, 2010 9:30 am

Post by uksitebuilder » Wed Dec 21, 2011 7:37 pm

check your config.php and admin/config.php urls are correct

post the contents of your .htaccess file here.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by rmarques » Wed Dec 21, 2011 7:53 pm

Here you can see the exact problem I'm having. Fido-x has a demonstration store here http://dev151.fido-x.net/admin/
username/password: demo/demo

Try to access it using Firefox and Chrome to see the difference.

On Firefox the login process never ends, on chrome it works just fine.

Like I said before, the main problem is for customers who use firefox, they will have problems to access their accounts.

My .htaccess is original, but even with seo urls turned off and htaccess.txt the problem happens.

All urls in config.php are correct.

The image attached shows what happens with admin login after some minutes.
open-cart-firefox-problem.png

Open Cart Firefox Login Problem - open-cart-firefox-problem.png (31.2 KiB) Viewed 7176 times


Newbie

Posts

Joined
Fri Sep 10, 2010 9:30 am

Post by uksitebuilder » Wed Dec 21, 2011 7:59 pm

works fine for me using FireFox.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by rmarques » Wed Dec 21, 2011 8:08 pm

So it might be a problem with my version of firefox. I'll work on firefox to see what I can find. Thanks!

Newbie

Posts

Joined
Fri Sep 10, 2010 9:30 am

Post by rmarques » Wed Dec 21, 2011 11:35 pm

I uninstalled AVG antivirus and reinstalled it again. Now opencart login works fine on firefox. Looks like there was a conflict somewhere.

Newbie

Posts

Joined
Fri Sep 10, 2010 9:30 am
Who is online

Users browsing this forum: Amazon [Bot] and 4 guests