Post by zingseo » Thu Mar 31, 2011 4:42 am

Hi

I am using the latest version of Opencart, 1.4.9.4
I am a real newbie and don't have much PHP knowledge. However I work in SEO and know that we need a 301 redirect to redirect example.com to http://www.example.com.

When I do this using a standard 301 redirect in a .htaccess file such as this:

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

I am no longer able to login to Opencart as admin.

Having read a bit here and elsewhere I understand that now opencart cannot resolve the admin url, or something like that.

It has been suggested that I do the 301 redirect like this:

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

Will that work?

Could someone just tell me in easy steps what I need to do to resolve this? If I need to edit files other than the .htaccess access file could you please make it easy to understand for me. Thanks :)
Last edited by zingseo on Thu Mar 31, 2011 10:44 am, edited 1 time in total.

Newbie

Posts

Joined
Thu Mar 17, 2011 10:09 am

Post by zingseo » Thu Mar 31, 2011 10:43 am

Okay. Have tried it out and talked to the hosting people. The second block of code works because it sends everything to the non www address which works with opencart. Thanks :)

Newbie

Posts

Joined
Thu Mar 17, 2011 10:09 am

Post by jackdent » Thu Mar 07, 2013 5:45 pm

I think I found the problem:

Once you have the www URL rewrite on, you need to modify TWO config.php files to include www before the rest of the URL

The first one is in the root directory, and the second in '/admin/'

You need to modify the files as follows, replacing your site with your site's URL

Code: Select all

// HTTP
define('HTTP_SERVER', 'http://yoursite.com/admin/');
define('HTTP_CATALOG', 'http://yoursite.com/');
define('HTTP_IMAGE', 'http://yoursite.com/image/');

// HTTPS
define('HTTPS_SERVER', 'http://yoursite.com/admin/');
define('HTTPS_CATALOG', 'http://yoursite.com/');
define('HTTPS_IMAGE', 'http://yoursite.com/image/');


// HTTP
define('HTTP_SERVER', 'http://www.yoursite.com/admin/');
define('HTTP_CATALOG', 'http://www.yoursite.com/');
define('HTTP_IMAGE', 'http://www.yoursite.com/image/');

// HTTPS
define('HTTPS_SERVER', 'http://www.yoursite.com/admin/');
define('HTTPS_CATALOG', 'http://www.yoursite.com/');
define('HTTPS_IMAGE', 'http://www.yoursite.com/image/');

Newbie

Posts

Joined
Thu Mar 07, 2013 5:41 pm

Post by tpk » Mon Oct 05, 2015 11:15 pm

Hi,

I have to take care of an already productive shop. I now want to achieve (for seo reasons) that domain.de and domain.de/cars are redirected to www.domain.de(/cars).

As Shop Version is 2.02 and the .htaccess looks rather complex to me I would like to ask again, how to achieve this best. I seemingly managed to achieve my goal by putting

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

right on top of the htaccess. And on all URLs in both config.php I added the www.

This seemed to work already, but then I realized, that calling domain.de (not domain.de/cars) called an Error and I also had to comment out:

#RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#RewriteCond %{HTTP_HOST} ^www\.comfortbaby\.de$

But that all felt too much like fiddeling around without really knowing what I am doing, so I rather ask how to do this propperly.

tpk
New member

Posts

Joined
Mon Oct 05, 2015 11:03 pm
Who is online

Users browsing this forum: No registered users and 60 guests