【问题标题】:Ban https access to the full web site but enable it for just one url禁止 https 访问整个网站,但仅对一个 url 启用它
【发布时间】:2011-10-29 23:33:47
【问题描述】:

我有一个 Apache 配置为拥有一个使用 ssl 和没有 ssl 的完整网站(仅 http),但我想只拥有 ssl,例如 https://www.mydomain.com/controller/action/params,其中没有控制器一个目录。换句话说,https://www.mydomain.com/ 或 https://www.mydomain.com/* 不应该是可访问的。

有谁知道如何做到这一点?

附:现在我正在尝试在.htaccess 文件中使用以下代码,但仍然没有运气。

RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} !controller/action/*
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]

【问题讨论】:

  • 离题。 Apache 配置不是编程。

标签: apache mod-rewrite ssl https


【解决方案1】:

request_uri 以“/”开头。在这种情况下,您也可以只使用 '*' 星表示 0 个或多个 '/' 字符。它应该看起来更像:

RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} !/controller/action/.*
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R,L]

【讨论】:

    猜你喜欢
    • 2020-03-08
    • 2010-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-03-01
    • 2022-06-16
    • 2020-11-03
    • 2020-10-17
    • 2015-01-14
    相关资源
    最近更新 更多