I just need to add 'https' remove 'www' in every case:
- user input in browser -> url output
- www.example.com -> https://example.com
- http://www.example.com -> https://example.com
- https://www.example.com -> https://example.com // NOT WORKING
I'm using following code:
RewriteEngine on
RewriteCond %{http_host} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,NC]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [R,L]
For whatever reason it works for the first two cases, but I can't make it work for the last one.
I couldn't even solve the last case isolated trying it e.g. like:
RewriteEngine on
RewriteCond %{https_host} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,NC]
Any help very appreciated!
i'm sure this is a duplicate but here the code i use: