htaccess, Redirect all requests to https://www [closed]
Want to improve this question? Update the question so it's on-topic开发者_运维技巧 for Stack Overflow.
Closed 11 years ago.
Improve this questionUsing .htaccess, I need to redirect all requests from
http://www.domain,
http://domain,
https://domain
to;
https://www.domain.com
How would I do this? I don't have any subdomains.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteCond %{http_host} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
That will direct all HTTP requests to https://www.example.com as well as redirect https://example.com to https://www.example.com.
Try this one...
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$ [OR]
RewriteCond %{HTTPS_HOST} ^domain.com$
RewriteRule ^(.*)$ "https\:\/\/www\.domain\.com\/$1" [R=301,L]
精彩评论