我正在尝试创建一个执行以下操作的 .htaccess 文件:
1 允许访问 EC2 运行状况检查 URL 而无需重定向到 https 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
如果您有任何建议,请告诉我如何让这个工作。