Place this rule in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} www\.
RewriteRule ^ https://domain.com%{REQUEST_URI} [L,R=301,NE]
Question
I need help with rewrite rules.
So I want that these addresses:
http://domain.com
http://www.domain.com
https://www.domain.com
Redirect to:
https://domain.com
Can someone help me?
Right now I have rule:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R,L]
But it doesnt redirect https://www to https://
Solution
Place this rule in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} www\.
RewriteRule ^ https://domain.com%{REQUEST_URI} [L,R=301,NE]