Reputation: 770
The redirect with .htaccess of the main domain without "www" like "mydomain.com" doesn't work, leaving the address in the ordinary http://, so what's wrong with this code? and how to force the redirect of all addresses to https://?
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
Upvotes: 0
Views: 163
Reputation:
Check these modified rules forcing without www and ssl
RewriteEngine On
# force to non-www
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,L]
# force to ssl
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L]
ErrorDocument 404 /404.php
Upvotes: 1