apache 如何配置成 用户输入www.xxx.com 自动跳转到https://www.xxx.com

阅读 6.6k
4 个回答

我对apache不熟悉,但是如果没记错的话,使用下面的 htaccess

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

在.htaccess文件中写入如下配置

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]

上面说的都是apache配置,这里我提供另外一种思路
可以通过apache指定http访问一个目录下 index.html
然后 文件利用

<meta http-equiv="refresh" content="0; url=https://www.xxx.com/" />

即可跳转

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题