Post by SXGuy » Sat Jan 07, 2017 5:37 pm

Hi Guys.

Some clients have complained that if the site is viewd without www. some things dont work, so ive tried to add rewrite conditions in the htaccess file but it doesnt appear to change anything.

Ive added

Code: Select all

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
Obviously changing example.com to the correct domain name, but when i navigate to the domain name without www it doesnt redirect, any advice?
Last edited by SXGuy on Mon Jan 09, 2017 11:05 pm, edited 1 time in total.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by ashwani_multi » Sat Jan 07, 2017 5:52 pm

Hi

please check config.php in that URL must be http://www.

Code: Select all

rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc] 

Opencart Quick checkout
View All modules
Any opencart issue contact me at support@opencartextensions.in

Thank you


User avatar
New member

Posts

Joined
Tue Dec 09, 2014 2:40 pm
Location - Ludhiana,Punjab,India

Post by opencartmart » Sat Jan 07, 2017 6:08 pm

Rewrite rules are correct. Could you please check following:

1. Is RewriteEngine enabled? If not, enable it by adding line RewriteEngine On in the htaccess
2. Is RewriteMod installed on your apache? Do your SEO URL work?

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by SXGuy » Mon Jan 09, 2017 4:21 am

Thanx for the replies. Yes seo keywords work. It's on in apache.

Rewrite engine is set to on also.

Another issue, when I add those rewrite conditions not only does it not redirect but any pages with seo keywords display error 404.

As I say, everything works prior to adding the rewrite conditions.

Http://www. Is already set in config.php

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by opencartmart » Mon Jan 09, 2017 1:18 pm

Please share full htaccess file

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by SXGuy » Mon Jan 09, 2017 10:56 pm

Please note, ive currently disabled htaccess and seo keywords until the problem is resolved, so just incase you were going to visit the domain, and notice seo keywords weren't working.

however the htaccess file is

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 "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# 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 /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/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)
RewriteCond %{HTTP_HOST} ^thekingsvapelounge.co.uk [NC]
RewriteRule ^(.*)$ http://www.thekingsvapelounge.co.uk/$1 [L,R=301,NC]


### 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

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am

Post by SXGuy » Mon Jan 09, 2017 11:05 pm

Hi please ignore last post, I just noticed the error in my htaccess file. Its now been fixed.

Thanks again.

Active Member

Posts

Joined
Sun Nov 08, 2009 2:07 am
Who is online

Users browsing this forum: No registered users and 285 guests