我有这样的配置。
我希望 /.well-known/acme-challenge/ 无需重定向即可工作,但其他一切都转到 https:// example.com
已经尝试过但是也不起作用。
<VirtualHost _default_>
ServerName example.com
Alias /.well-known/acme-challenge/ /letsencrypt/.well-known/acme-challenge/
Redirect / https://example.com/
</VirtualHost>
答案1
这可以通过 RewriteEngine 来实现:
<VirtualHost _default_>
ServerName example.com
Alias /.well-known/acme-challenge/ /letsencrypt/.well-known/acme-challenge/
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/.well-known/
RewriteRule /(.*) https://example.com/$1 [R,L]
</VirtualHost>