Jump to content
OrganizedFellow

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

Recommended Posts

#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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

I tried the above suggestion. It still doesn't work after restarting apache. Any idea why?

 

I am stumped.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...