Trying to redirect all http
and none-www
traffic to https
(with or without www).
Using .htaccess
and apache VirtualHost
files:
VirtualHost file
<VirtualHost *:80>
ServerName adi-md.co.il
ServerAlias www.adi-md.co.il
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{HTTP_HOST} ^adi-md.co.il
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L,NE]
#RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
#RewriteRule (.*) https://www.%1%{REQUEST_URI} [L,R=301]
#RewriteCond %{HTTP_HOST} ^www.adi-md.co.il
option 1
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^adi-md.co.il
option 2
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://www.%1%{REQUEST_URI} [L,R=301]
When typing just adi-md.co.il
you get the the server's default page.
How do I fix it so all traffic is both redirected to https
as well as the none-www
requests??
Note: I have looked at these 3 but they do not supply an answer (2 out 3 deal with www to none-www)
apache redirect http to https and www to non www
http to https apache redirection
Redirect from http to https without www using .htaccess