Prestashop second store redirects to main when www. is used - prestashop

good afternoon everyone,
I have a multistore with 3 stores. Unfortunately www.domain.nl refers to the main domain and domain.nl does not go to the right shop. Now I had a solution for that in the past, which is:
RewriteCond %{HTTP_HOST} !^www. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
However, if I now put this in the htaccess, the sites all give a "To many redirects error"
I can't figure it out and ask for your help.

I have found finaly the solution:
To redirect from www. to non www use below in your htaccess.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Related

.htaccess file making new domain redirect to my original domain

To give a little background that may help understand this. I only had one domain on my host's server initially. I just added a new domain and it was redirecting to my first site.
I had to create an .htaccess file redirect my first site so that it would have my SSL on every page and so that it took the www. away from the sites name. The www. was causing issues with sessions when a customer would login.
So my code was like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,NE,L]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
The tech support of my host company said that this line was making my new site redirect to my old site:
RewriteRule ^(.*) https://%1/$1 [R=301,NE,L]
How can I make my code work so that is still has the exact same functionality of what it was doing and not interfere with my new domain and make it re-route to my old site?
Why not just exclude the new site, if I am understanding correctly?
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?newsite\.com [NC]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com [NC]
RewriteRule ^(.*)$ https://oldsite.com/$1 [R=301,NE,L]
RewriteCond %{HTTPS} ^off
RewriteCond %{HTTP_HOST} !^(www\.)?newsite\.com [NC]
RewriteRule ^(.*) https://oldsite.com/$1 [R=301,NE,L]
Alternatively maybe you can just tell it to not do anything based on the host. Try putting this at the top of your rules.
RewriteCond %{HTTP_HOST} ^(www\.)?newsite\.com [NC]
RewriteRule ^ - [L]
Note I haven't tested this.

Migrate one domain to another and force https on new domain

I am trying to migrate one domain to a new domain as well as force everything to https.
I have tried a few iterations using .htaccess with no luck.
One thing I tried was:
RewriteCond %{HTTP_HOST} !newsite.com$ [NC]
RewriteRule ^(.*)$ https://www.newsite.com/$1 [L,R=301]
This redirects everything except the oldsite https links.
Also have tried other options like:
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(.+)\.oldsite.com\.com$ [NC]
RewriteRule (.*) https://newsite.com/$1 [L,R=301,QSA]
RewriteCond %{HTTP_HOST} !newsite.com$ [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [L,R=301]
Also with no luck.
I imagine I am missing something quite simple...any tips would be appreciated!
Besides unescaped . character, your initial attempt is correct. To redirect one domain to another and switch to HTTPS connection, considering that there are other sites pointing to the same document root:
RewriteEngine on
RewriteCond %{HTTP_HOST} !newsite\.com$ [NC]
RewriteRule (.*) https://www.newsite.com/$1 [R=301,L]
UPDATE:
Although the rule above is correct, redirection from https://www.oldsite.com to https://www.newsite.com didn't occur for original poster because newsite.com didn't have a valid certificate.

htaccess wildcard redirect not working

I have an htaccess wildcard redirect on a website, it redirect another domain to a main one and also redirects www to none www with wildcard for the main domain. The following rules are made with cpanel, however it does not use the wildcard.
These same rules work fine on many other sites just not the one in question.
RewriteCond %{HTTP_HOST} ^www\.domain1\.ca$
RewriteRule ^(.*)$ "http\:\/\/domain1\.ca\/$1" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$
RewriteRule ^(.*)$ "http\:\/\/domain1\.ca\/$1" [R=301,L]
Any ideas? I am out of ideas for what could be causing this.
To add more clarification:
if i go to www.domain1.ca/some-page it should redirect to domain1.ca/some-page
However instead it goes to domain1.ca.
Tested in every browser, remade the rules, removed all cache and did multiple dns flush's, nothing has changed this.
You can use:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteRule ^ http://domain1.ca%{REQUEST_URI} [R=301,L,NE]

htaccess redirect www (es) to non www (es)

I'm currently redirecting all requests for www.example.com to example.com.
I have this working nicely with this code found elsewhere on stackoverflow:
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
So far so good.
The problem I have is that I also need to ensure that the Spanish version of my site also redirects — www.example.com/es needs to redirect to example.com/es, but this doesn't work with the code shown above.
What would I need to add to make the redirection work?
Thanks for your help!
Inside your example.com/es/ folder, create a .htaccess file with the following contents:
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/es/$1 [L,R=301]
(Reference)

HTACCESS Rewrite on directories

I have the following code in my Root htaccess file
RewriteCond %{HTTP_HOST} ^paperviewmagazine.com
RewriteRule (.*) http://www.paperviewmagazine.com/$1 [R=301,L]
It works fine for the main site, but for my forums at /forums/ if someone misses off the www it will show the page and not redirect to the www.paperviewmagazine.com/forums/ instead.
I need to force the WWW to prevent anyone from logging in by accident on the non-www as it wont have the correct cookie credentials for accessing the site at www./forums/
Can anyone help?
Thanks.
If you are just trying to route "site.com" to "www.site.com" then do:
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.example.com/$1 [L,R=301,NE]