vendredi 26 juillet 2019

htaccess redirect https://www. (https://www.example.com) to non www (https://example.com)

I'm trying to redirect all requests from http to https and all requests from www. to non www (https://) but no matter what i try it is not working. Specifically the redirect from https://www.example.com to https://example.com is not working. Everything else works fine. I've tried many different ways i found here on stackoverflow and other posts on the internet but none of them are working for me. When i go to https://www.example.com i get a certificate warning cause the certificate is issued to https://example.com. I'm really giving up on this one as i've tried it for two days now ...

This is the code i'm using right now

RewriteEngine on
# www -> https without www
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
# http -> https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]




Aucun commentaire:

Enregistrer un commentaire