开发者

HTTP to HTTPS using mod_rewrite

开发者 https://www.devze.com 2022-12-20 21:34 出处:网络
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:

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消