gpt4 book ai didi

.htaccess - 如何启用 SSL 排除特定目录和排除子域

转载 作者:太空宇宙 更新时间:2023-11-03 14:34:07 25 4
gpt4 key购买 nike

我要:

  1. 将“domain.com”规范化为“www.domain.com”
  2. 启用 SSL,但是:
  3. 从/PHP/* 中排除 SSL
  4. 从特定页面“noSSL.htm”中排除 SSL

这是我的:

#enable SSL excluding /PHP directory
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule !^php/.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

#Enable SSL and add "www." if missing
RewriteEngine On
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ https%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

问题/问题:

  • 问题:子域获取 SSL
  • 如何从 SSL 中排除特定文件?
  • 我需要重复“RewriteEngine On”吗?

非常感谢任何帮助!

最佳答案

根据您的评论,规则应如下所示:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteCond %{SERVER_PORT} !=443
RewriteRule !^(php/.*|.*noSSL\.htm)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

因此 noSSL.htm 将被排除。

注意:清除浏览器缓存然后测试。

关于.htaccess - 如何启用 SSL 排除特定目录和排除子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49731444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com