HTTP to HTTPS using mod_rewrite
I'm looking for a simple way to have this done. I would to have the .htaccess file rewrite to HTTPS if this is typed in the address bar:
- www.example.com
- example.com
- http://www.example.com
I would like any of these potabilities redirect to https://www.example.com
Thanks guys... I haven't found anything for this situation.
Just wanted to say that the answer be开发者_如何学Pythonlow did not work for me... is there anything else I can do?
Try this:
RewriteEngine on
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !=www.example.com
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
The easiest way to do this is to check the port the request is coming in on.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.org/$1 [R=301,L]
精彩评论