HTTP到HTTPS使用mod_rewriteHTTP、HTTPS、mod_rewrite

2023-09-02 00:46:37 作者:小可爱1号

我在找一个简单的方法来已完成这件事。我想有.htaccess文件重写到HTTPS如果这是输入在地址栏中输入:

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 的 www.example.com example.com http://www.example.com

我想任何这些potabilities重定向到的 https://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 below did not work for me... is there anything else I can do?

推荐答案

试试这个:

RewriteEngine on
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !=www.example.com
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]