我有以下 Apache 配置:
<VirtualHost *:80>
Alias "/.well-known" "/var/www/example.com/.well-known"
RewriteEngine On
<If "%{HTTP_HOST} == 'example.com'">
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</If>
<ElseIf "%{HTTPS} != 'on'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</ElseIf>
</VirtualHost>
我想要Alias
免除 HTTPS 重定向,即http://example.com/.well-known/x
应该返回文件/var/www/example.com/.well-known/x
。目前,它正在按照RewriteRules
以下方式重定向到 HTTPS。
我怎样才能免除Alias
重定向?
答案1
<If "%{HTTP_HOST} == 'example.com' && !(${REQUEST_URI -strcmatch '/.well-known/*')" >
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</If>
<ElseIf "%{HTTPS} != 'on' && !(${REQUEST_URI -strcmatch '/.well-known/*')">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</ElseIf>