问题原文
原帖链接 · starchx · CC BY-SA 3.0
User Request: https://www.example.com/test
HTTPS requests --> AWS ELB HTTPS Listener --> Apache HTTP
Apache getting http://www.example.com/test
Apache redirect it to http://www.example.com/test/ due to DirectorySlash is On by default.
User ends up with a HTTP request: http://www.example.com/test/
AWS provides a HEAD to detect origin request protocol: %{HTTP:X-Forwarded-Proto}, but how do I tell Apache mod_dir DirectorySlash to use that Header?
Please advise your solution or workaround in this scenario.
已采纳解答
原帖链接 · starchx · CC BY-SA 3.0
Since rewrite will kick in before DirectorySlash, here is what ended up with and it works:
# Redirect to HTTPS before Apache mod_dir DirectorySlash redirect to HTTP
RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteCond %{LA-U:REQUEST_FILENAME} -d
RewriteRule ^/(.*[^/])$ https://%{HTTP_HOST}/$1/ [R=301,L,QSA]
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
