哪里允许使用 RewriteMap?

laz*_*tem 5 mod-rewrite rewritemap apache-2.2

这似乎是一个非常简单的问题。

我尝试将 RewriteMap 指令放在 .htaccess 文件中,但日志显示警告:

RewriteMap not allowed here
Run Code Online (Sandbox Code Playgroud)

然后我尝试将它放在 apache2/sites-available 文件中的 VirtualHost 声明中,但是重新加载 apache 给了我:

RewriteMap not allowed here
...fail!
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,都启用了 RewriteEngine。

这是指文件系统上实际映射的位置,还是 RewriteMap 指令?

以防万一它有帮助:

<VirtualHost *:80>
  ServerName localhost
  etc...
  <Directory /var/www/site>
  AllowOverride all
  Options Indexes FollowSymLinks MultiViews
  Order allow,deny
  Allow from 127.0.0.1
  RewriteEngine On
  RewriteMap map txt:/var/www/site/map.txt
  RewriteRule /path/[^/]+/([^/]+) ${map:$1} 
  etc...
Run Code Online (Sandbox Code Playgroud)

小智 9

根据官方文档,它只允许在服务器配置、虚拟主机的范围内(上下文:在信息框中)。将它放在目录指令之外,它将起作用。