Apache自动跳转到 HTTPS Apache设置http跳转https

[复制链接]
希望工程bossLv.7 显示全部楼层 发表于 2020-4-24 16:23:10 |阅读模式 打印 上一主题 下一主题
安卓上架
Apache自动跳转到 HTTPS Apache设置http跳转https

网站根目录新建 .htaccess
  1. RewriteEngine On
  2. RewriteCond %{SERVER_PORT} 80
  3. RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
复制代码


站点绑定多个域名,只允许www.example.com 跳转

  1. RewriteEngine On
  2. RewriteCond %{SERVER_PORT} 80
  3. RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
  4. RewriteCond %{HTTP_HOST} ^www.example.com [NC]
  5. RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
复制代码
******把网址更改为自己的******



高级用法 (可选)
RewriteEngine on

  1. # 强制HTTPS
  2. RewriteCond %{HTTPS} !=on [OR]
  3. RewriteCond %{SERVER_PORT} 80
  4. # 某些页面强制
  5. RewriteCond %{REQUEST_URI} ^something_secure [OR]
  6. RewriteCond %{REQUEST_URI} ^something_else_secure
  7. RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
  8. # 强制HTTP
  9. RewriteCond %{HTTPS} =on [OR]
  10. RewriteCond %{SERVER_PORT} 443
  11. # 某些页面强制
  12. RewriteCond %{REQUEST_URI} ^something_public [OR]
  13. RewriteCond %{REQUEST_URI} ^something_else_public
  14. RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
复制代码






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

一门APP打包致力于H5混合APP基础框架领域的前沿探索,专注轻便的移动应用解决方案 提供基于HTML前端页面在各种应用层级的端延展。
  • 官方手机版

  • 微信公众号

  • 微信客服

  • Powered by Discuz! X3.4 | Copyright © 2001-2020, 一门APP. | 一门APP开发平台|热门标签
  • 蜀ICP备17005078号-4 | 川公网安备 51019002001185号 | |成都七扇门科技有限公司