Post by Tromas » Tue Jul 12, 2011 7:32 pm

I discovered that if customers go to example.com instead of www.example.com, the add to cart button don't work (1.5.05 version) on the front page.

Does the following code look ok? I added to two last lines.
I' just not sure if it's ok to use two RewriteRules. ???

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Anbefalt vibrator
Dildo i glass og metall
Myke sex leketøy i silikon


New member

Posts

Joined
Sat Feb 12, 2011 1:06 am


Post by MattW » Tue Jul 12, 2011 9:24 pm

This is how I have mine:

Code: Select all

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

Image


User avatar
New member

Posts

Joined
Sat Aug 28, 2010 11:37 am
Location - Sheffield

Post by webpie it. » Tue Jul 12, 2011 11:41 pm

I have been old before that this could be down to a jquery thing where it is only set to www.example.com with the prefix.

I advice you do what MattW has done as this fixed my issue with jquery and missing WWW. prefix

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by Tromas » Sat Oct 08, 2011 10:00 pm

I have tried MattW's method, but then I couldn't log into my admin panel.

I get the log in screen, but nothing happens when I try to log in.

Anything I need to change in config.php in my admin map? ???

Edit: solved

just had to add some www. in the config.php (admin map).

Anbefalt vibrator
Dildo i glass og metall
Myke sex leketøy i silikon


New member

Posts

Joined
Sat Feb 12, 2011 1:06 am


Post by uksitebuilder » Sat Oct 08, 2011 11:52 pm

Here is the code I use - Hope it helps

Code: Select all

RewriteBase /
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]

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

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

Post by hoo91 » Sat Nov 26, 2011 2:10 am

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.

Newbie

Posts

Joined
Thu Jan 28, 2010 1:53 pm

Post by uksitebuilder » Sat Nov 26, 2011 2:36 am

That's because RewriteBase should have a trailing slash

i.e.

RewriteBase /shop/

not

RewriteBase /shop

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

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

Post by hoo91 » Mon Nov 28, 2011 11:56 am

Thanks for your reply. I changed /shop to /shop in my htaccess file and that didn't solve my problem. The redirect works perfectly when i access my site with the /shop directory or any directories within the /shop directory. But if I go to my domain without the /shop directory and without typing www, it does not redirect correctly. Any other suggestions?

Newbie

Posts

Joined
Thu Jan 28, 2010 1:53 pm

Post by uksitebuilder » Mon Nov 28, 2011 4:08 pm

Here is the Rewrite section that I would use

RewriteEngine On
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]

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

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

Post by emilygraham » Mon Nov 28, 2011 7:15 pm

Hi Simon,

I have tried using the code you printed above to redirect from non-www to www, whilst still retaining SEO friendly URLS, but it is not working as expected and not transferring from non-www to www. Is there anything else that needs configuring? My config files say http://domainname.co.uk... as opposed to http://www.domainname.co.uk, but changing this resulted in a 'page not found error' Any ideas?

New member

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by uksitebuilder » Mon Nov 28, 2011 7:25 pm

Hi,

Well your config file should read as follows:

Code: Select all

http://www.yourdomain.com/shop/
the trailing slash is important

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

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

Post by emilygraham » Mon Nov 28, 2011 7:27 pm

Hi Simon,

My config files currently read using the format:
define('HTTP_SERVER', 'http://domain.co.uk/');
If i change that to:
define('HTTP_SERVER', 'http://www.domain.co.uk/');
i get a 'page not found error' when viewing the site

does the prefix www. need to be set anywhere else?

New member

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by uksitebuilder » Mon Nov 28, 2011 7:30 pm

you missed the /shop/ off the end

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

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

Post by emilygraham » Mon Nov 28, 2011 7:35 pm

even if my website is at the root level (i.e not under the folder 'shop')?

New member

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by emilygraham » Mon Nov 28, 2011 8:00 pm

Its actually not a 'page not found error' but a 'oops! This link appears to be broken' error. Typing the URL http://domain.co.uk/designers works fine, but the URL http://www.domain.co.uk/designers gives the 'Oops! This link appears to be broken' error - makes me think that somewhere i am specifying a non-www URL but no idea where???

New member

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by emilygraham » Mon Nov 28, 2011 8:36 pm

Hi Simon,

Made a bit more progress now - appologise, i was missing a line in the .htaccess file. All redirects are working fine now and the SEO friendly URLs. Using the code you pasted though (copied my version below), i am not able to login to administration though which is obviously causing me some problems !?

RewriteEngine On
RewriteBase /
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]

Many thanks for your help
Emily

New member

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by emilygraham » Mon Nov 28, 2011 8:55 pm

Would you believe me if i now said it was all working correctly !?! Able to login no problems, maybe something was cached....thanks for your help

New member

Posts

Joined
Wed Sep 14, 2011 7:26 pm

Post by albsim81 » Tue Jan 17, 2012 6:30 pm

When you install opencart you have to choose between www or non-www url.
Probably you chose non-www so now you must choose the same in .htaccess

Here the solution http://forum.opencart.com/viewtopic.php?f=20&t=29515

Sigaretta elettronica Opencart 1.5.4.1 italian translation


New member

Posts

Joined
Wed Jan 26, 2011 5:14 am
Location - Italy

Post by newtress » Sat Jul 06, 2013 9:45 am

While this seems to work well to help the code redirect, how do you avoid getting subdomains to redirect as with the rest of the site. For example if you have the subdomain 'test' at http://test.domain.com, how do you avoid it from becoming http://www.test.domain.com, which for obvious reasons will not work.

Newbie

Posts

Joined
Mon Jun 17, 2013 4:54 pm

Post by newtress » Sat Jul 06, 2013 9:55 am

Nevermind, I just figured this out. It seems all you have to do is create a condition that places the sub-domain in a no case rule to stop it from being part of the decision, as below, based on your subdomain of course.

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

Ya, glad we figured that out. Now you can see our redirects at http://newtress.com. It should go to http://www.newtress.com.

Newbie

Posts

Joined
Mon Jun 17, 2013 4:54 pm
Who is online

Users browsing this forum: No registered users and 8 guests