Jump to content

can not 301/redirect non-www to www :(


OrganizedFellow
 Share

Recommended Posts

Straight from the ProcessWire .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{SERVER_ADDR} !=127.0.0.1
RewriteCond %{SERVER_ADDR} !=::1
RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

That should work right away... are you using a real hosting account or something like Github pages or Netlify?

Link to comment
Share on other sites

What wbmnfktr said. Also it might be a good idea to check that .htaccess is actually in use: I usually check this just by inserting something obviously broken there; if the site still works, the whole .htaccess file is likely being ignored ?

Note: you don't have to restart Apache after .htaccess changes, they will work (or not work...) instantly.

Link to comment
Share on other sites

  • 4 months later...
  • 5 months later...

 

On 6/7/2020 at 6:59 PM, eydun said:

What is the reason that this is set?


RewriteCond %{SERVER_ADDR} !=127.0.0.1

I need to remove it to make it work on my production server.

Just jumping in to say that I had to also remove this line in order for www. forwarding to work.

I think its supposed to check that is not running locally, so we don't force www. but even in prod my servers are running on localhost/ 127.0.0.1. 

CC @ryan as there may be a bug in the htaccess. Alternatively it may just need an updated comment to remove that line in prod ¯\_(ツ)_/¯

  • Like 1
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...