HTTP到HTTPS使用mod_rewrite [英] HTTP to HTTPS using mod_rewrite

查看:91
本文介绍了HTTP到HTTPS使用mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找一个简单的方法来已完成这件事。我想有.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]

这篇关于HTTP到HTTPS使用mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆