"Require all granted" 在 Apache VirtualHost 配置中,但仍然 "You don't have permission to access /test on this server"(RewriteRule 失败)

"Require all granted" in Apache VirtualHost config but still "You don't have permission to access /test on this server" (RewriteRule fails)

以下是 /etc/apache2/sites-available/000-default.conf Debian 上 Apache 2.4 配置文件的完整内容:

<VirtualHost *:80>
  ServerName 203.0.113.0
  DocumentRoot /home/www/203.0.113.0
  <Directory "/">
    Require all granted   # as required with Apache 2.4
  </Directory>
  RewriteEngine On
  RewriteRule ^/test(.*)$ /index.html [P,L]
</VirtualHost>

问题:为什么访问http://203.0.113.0/test显示:

Forbidden
You don't have permission to access /test on this server.
Apache/2.4.25 (Debian) Server at ... Port 80

终于

cat /var/log/apache2/error.log 

给出解决方案:

AH00669: attempt to make remote request from mod_rewrite without proxy enabled

所以

a2enmod rewrite proxy proxy_http

解决了问题。