例如,一个 apache 实例正在管理
www.site.com/folder1/a.html
www.site.com/folder2/b.html
www.site.com/folder3/c.html
我需要确保
www.site.com/folder3/c.html
只能访问 https。
所有这些文件夹都在同一个文档根目录中。
这可能吗?如果没有,您推荐什么作为获得我想要的所需的最小更改?
你可以试试这个解决方案:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/folder3/c.html$ https://www.site.com/folder3/c.html$1 [R,L]
使用此解决方案,您还可以定义应用哪种重定向。而且,最重要的是,该规则只会在 HTTP 方案中运行。
我相信您可以在 Apache 配置中执行以下操作:
RedirectMatch /folder3/(.*) https://www.site.com/folder3/$1
不确定这是否正确。
希望有帮助...