Reputation: 707
My htaccess file has me utterly confused. First it gave me a mixed content warning on chrome whilst working properly, after changing it it no longer does that, but also somehow no longer redirects the main domain to https.
This is what I want:
/index.php
to /
www
to non-www
non-https
to https
This is what my .htaccess file looks like right now:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
I honestly don't see any issues with it. It works fine if I go directly to /index.php
, it works fine when going directly to https://...
or www.domain.net
but it doesn't work when I go to the domain.net
.
Upvotes: 0
Views: 89
Reputation: 4302
So many issues at your code like these two lines :
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
you match all https
and www
and not when they not exist
Try this :
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://www.growconomy.net/$1 [L,R=301]
RewriteRule ^index.php$ / [L,R=301]
Note: clear browser cache then test it
Upvotes: 1
Reputation: 736
You're only including www as a subdomain to redirect:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
You might remove it or change it to something like:
RewriteCond %{HTTP_HOST} ^(.+)\.(.*)$ [NC]
Upvotes: 1