I was searching the web for an example to redirect everything without www
and found the following:
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
I don't know exactly what it does
Options All -Indexes
Options +FollowSymLinks
and trying with some examples without success.
But it does not work, I can enter without problems and, it does not redirect me tohttps
What I want to achieve, is that if you enter my website like this:
www.example.com/
example.com/
o
http://www.example.com/
http://example.com/
Always redirect to:
https://example.com/
no use ofwww
Try the following way.
WITHOUT www (all visits go to " https://domain.com "):
The problem is that your rule set redirects only when the string
www.
at the beginning of the URL is not present. You do this with this rule:You can solve it by removing that line from the apache config file, restarting the service and it should work as expected.