OrganizedFellow Posted January 17, 2020 Posted January 17, 2020 #Force www: RewriteEngine On RewriteCond %{HTTP_HOST} ^915website.com [NC] RewriteRule ^(.*)$ http://www.915website.com/$1 [L,R=301] my static site is no redirecting as expected ? i have my htaccess at the root alongside index.html and style.css
wbmnfktr Posted January 17, 2020 Posted January 17, 2020 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?
OrganizedFellow Posted January 18, 2020 Author Posted January 18, 2020 7 hours ago, wbmnfktr said: That should work right away... are you using a real hosting account or something like Github pages or Netlify? A droplet on Digital Ocean running a LAMP stack (see my sig).
OrganizedFellow Posted January 18, 2020 Author Posted January 18, 2020 I tried the above suggestion. It still doesn't work after restarting apache. Any idea why? I am stumped.
wbmnfktr Posted January 18, 2020 Posted January 18, 2020 I guess you followed your instructions so... I'm quite clueless as well. I just stumbled across this: https://stackoverflow.com/a/26336358 - maybe it helps to check if it actually works at all. 1
teppo Posted January 18, 2020 Posted January 18, 2020 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.
eydun Posted June 7, 2020 Posted June 7, 2020 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.
StanLindsey Posted November 13, 2020 Posted November 13, 2020 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 ¯\_(ツ)_/¯ 1
Recommended Posts