Post by SupraTwinTurbo » Wed Apr 20, 2011 8:08 am

I am using the latest version of OpenCart (1.4.9.4). I have set the store URL in System > Settings > General to be

http://www.mysite.com/

However, if I type in mysite.com in my browser, the URL is without WWW : http://mysite.com/

Here is my .htaccess contents:

Code: Select all

# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName hdrshots.com
AuthUserFile /home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp

Options +FollowSymlinks

# Prevent Directoy listing 
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log|txt)">
 Order deny,allow
 Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ http://www.mysite.com? [R=301,L]
Is there something wrong with my .htaccess file? Any help would be appreciated.

User avatar
New member

Posts

Joined
Thu Mar 24, 2011 12:43 pm
Location - NYC, NY USA

Post by RonA » Wed Apr 20, 2011 9:20 am

Try placing the following three lines in your .htaccess file .... it works very well for me.

Code: Select all

 # REDIRECT NON-WWW
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteRule ^/?$ "http\:\/\/www\.yourdomain\.com" [R=301,L]

New member

Posts

Joined
Tue Mar 09, 2010 4:11 pm

Post by sdynak » Thu May 16, 2013 3:50 am

Just wanted to say this worked for me with two different sites/installs doing the same thing .. thanks Ron for posting your resolution. Why these things are not standard are beyond me.. seems like OC likes to challenge us :)

New member

Posts

Joined
Wed Jan 02, 2013 8:52 am
Location - Bayville, New Jersey

Post by p3nsy » Tue Jun 14, 2016 5:20 pm

Works like a charm! Thanks so much for the solution!

Newbie

Posts

Joined
Fri Jan 29, 2016 3:19 am

Post by ali00h » Thu Mar 29, 2018 4:56 pm

If you don't want to manipulate the htaccess file, just use this extension:
https://www.opencart.com/index.php?rout ... n_id=33165

Newbie

Posts

Joined
Sat Mar 17, 2018 4:12 am

Post by straightlight » Thu Mar 29, 2018 6:39 pm

Take note the suggestion above has been posted in the v1.5x section of the forum but the offered extension is available for OC v2.x and v3.x releases.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Lucmac » Sun May 05, 2019 8:00 pm

In my particular case it was in fact the config.php file that was causing this, in particular

Code: Select all

define('HTTP_SERVER', 'https://mybutik.com/');
I simply inserted the www. and it works like a charm. I did this for both config.php files, front end and back end.

New member

Posts

Joined
Mon Apr 22, 2019 5:29 pm

Post by garrie007 » Sat May 11, 2019 9:44 pm

Lucmac wrote:
Sun May 05, 2019 8:00 pm
In my particular case it was in fact the config.php file that was causing this, in particular

Code: Select all

define('HTTP_SERVER', 'https://mybutik.com/');
I simply inserted the www. and it works like a charm. I did this for both config.php files, front end and back end.

whats the location of both config files, cheers.

New member

Posts

Joined
Mon Apr 08, 2019 5:39 am
Who is online

Users browsing this forum: No registered users and 307 guests