cancel
Showing results for 
Search instead for 
Did you mean: 

Magento2 can't access to magento2 with www but enable without www i.e domain.com

SOLVED
   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

I've added this lines:

 

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

Now redirect always query to non-www but still i got domain.com/index.php...

I've cleared browser and open in private window but nothing changed Smiley Sad

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

I've added your lines after RewriteBase / and index.php is gone Smiley Happy

But when i've added your first two lines and added RewriteBase / with few lines after that page doesn't work even without www. I don't know why Smiley Sad

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

In firefox works, in private mode chrome works but... I clear cache open new window and doesn't work for chrome in normal mode... wtf.

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

then looks like browser cache issue.

Please clear chrome browser cache and cookie once and check.

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

I've cleaned cached and i can enter to page with www but i've got another problem. Now i can only get access to main site i.e domain.com but to other sites even admin panel i can't get access.

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

try to update last line:

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

I have added /$1

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

Now, instead error 404 i've got error 411. but when i comment this line everything works fine but i need redirect from http to https. Any clue how can i do this thing?

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

for https:

you can add https url in unsecure and secure url and change setting
use for frontend = "Yes"

use for admin = "Yes"

now I will not suggest more experiment with .htaccess Smiley Happy

BTW did you try in your code instead of off ?

RewriteCond %{HTTPS} on



Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

I've change to this lines and it works:

 

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

I hope will works correctly finally Smiley Happy

Re: Magento2 can't access to magento2 with www but enable without www i.e domain.com

@patryk_przebiro 
Did it work completely?


then please mark as solution so it will help to others as well.