.htaccess 是否将特定子域重写为基于SSL的?
我在Debian7上使用Apache2 我在以下位置安装了一个在线工具:.htaccess 是否将特定子域重写为基于SSL的?,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我在Debian7上使用Apache2 我在以下位置安装了一个在线工具: 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 这
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
这可能吗?如果我正确理解了您的意思,您希望只重定向到HTTPS的子域
工具.myurl.net
,因此此规则应该可以:
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]
请澄清你的问题。