【发布时间】:2017-02-14 00:04:46
【问题描述】:
我正在尝试创建一个执行以下操作的 .htaccess 文件:
1 允许在不重定向到 https 的情况下点击 EC2 运行状况检查 URL 2 将所有非 https 流量重定向到 https 3 将调用重定向到 / 到 /auth/app/public/app(使用 https)
第 2 项和第 3 项工作正常,但运行状况检查很快失败,服务器不再响应。这是我的 .htaccess 文件的内容:
RewriteEngine On
#one attempt that didn't work
#RewriteCond %{HTTP_HOST} !^my\.domain\.com$ [NC]
#RewriteCond %{REQUEST_URI} !^/healthcheck.html$
#RewriteRule ^ http://my.domain.com/$1 [R=301,L]
#another attempt that didn't work
#RewriteCond %{HTTP_HOST} !$ [NC]
#RewriteCond %{REQUEST_URI} !^/healthcheck.html$
#RewriteRule ^(.*)$ /$1 [L,QSA]
#this works
RewriteRule ^$ https://my.domain.com/auth/app/public/app/ [L]
#this works
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://my.domain.com%{REQUEST_URI} [L]
前两个被注释掉的尝试来自我在https://serverfault.com/questions/470015/how-should-i-configure-my-elb-health-check-when-using-namevirtualhosts-and-redir 找到的示例 和https://serverfault.com/questions/470015/how-should-i-configure-my-elb-health-check-when-using-namevirtualhosts-and-redir/597541#597541
如果您有任何建议,请告诉我如何让它工作。
【问题讨论】:
-
我会尝试一个简单的
RewriteRule ^healthcheck\.html$ - [L]——当请求的 URL 是healthcheck.html时,不要重写任何东西 (-),并将其作为最后一条规则。这应该不需要任何额外的 RewriteConds。
标签: .htaccess ssl elastic-load-balancer