xtrman
xtrman

Reputation: 421

how to force non-www when person visits website store

I have a script on my website that is a module addon for opencart. I tried working with the developer but this is what he told me.

The browser will block the ajax request as a cross domain request. This is just how scripts and browsers work it has nothing to do with my mod. You need to put a redirect in your .htaccess to make sure that people always wind up on the proper domain non-www.

and

they are are ajax requests. I'm not sure how you would enable them for cross domain support.

The issue is pretty much when I load my website, i have a script. a car make, model, year chooser, it works for some people and not for others. I realized it was with the www. infront of the domain. When the www. is removed it works for everyone, when it is added it stops working for everyone.

Is there a way to force non-www. on my website store directory /store/

I have tried this but it says an error

The page isn't redirecting properly Browser has detected that the server is redirecting the request for this address in a way that will never complete.

RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ http://%2%{REQUEST_URI} [R=301,L]

Upvotes: 2

Views: 80

Answers (1)

anubhava
anubhava

Reputation: 784998

Is there a way to force non-www. on my website store directory /store/

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^store(/.*)?$ http://%1%{REQUEST_URI} [R=301,L,NC,NE]

Upvotes: 2

Related Questions