I have a problem with .htaccess
I have a certificate in my server, and it's only for https://example.com (not https://www.example.com) Therefore, I'm trying to do a .htaccess redirect to the correct url.
My intention is this:
http://www.example.com --> https://example.com
http://example.com --> https://example.com
https://www.example.com --> https://example.com
I tried different combinations and nothing seems to work. At the moment I have this, but seems like is not working for
http://www.example.com/subfolder
, I don't know what is failing...
RewriteEngine On
# Follow symbolic links.
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# Prevent directory listings
Options All -Indexes
That code is not working for me, I found that, which works for me
Replace your current code by this one