【问题标题】:Rewrite specific sub domain to SSL based?将特定子域重写为基于 SSL 的?
【发布时间】:2013-08-23 17:02:15
【问题描述】:

我在 Debian 7 上使用 apache 2。

假设我安装了一个在线工具:

tool.myurl.net

我确实有一个通配符 SSL 证书:

*.myurl.net

我还在 Apache 中配置了 virtualhost 以使用 ServerAlias 监听 tool.anotherurl.com

但我没有该 URL 的有效 SSL 证书。

所以我需要一个重写规则,将http://tool.myurl.net 重定向到httpS://tool.myurl.net 但不是当人们访问http://tool.anotherurl.com 时。

这可能吗?

【问题讨论】:

  • 请澄清您的问题。

标签: .htaccess mod-rewrite url-rewriting


【解决方案1】:

如果我理解正确,您只想将子域tool.myurl.net 重定向到 HTTPS,所以这条规则应该这样做:

RewriteEngine On
# if HTTPS is not being used we force it to HTTPS
RewriteCond %{HTTPS} !=on
# because we want to force it for this domain only
RewriteCond %{HTTP_HOST} ^tool\.myurl\.net$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

【讨论】:

    猜你喜欢
    • 2010-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多