Apache:如何在Alias中使用重写引擎


Apache : How to Use Rewrite Engine Inside Alias

我有这个别名配置:

Alias /test/ "D:/WWW/Test/"
<Directory "D:/WWW/Test/">
    Order allow,deny
    Allow from all
</Directory>

然后在D:/WWW/Test/目录中,我使用以下配置放置.htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^([^.]*'.css)$ resources/$1 [L,NC]
</IfModule>

我只想将所有请求从localhost/test/css/*重定向到localhost/test/resources/css/*

但似乎忽略了.htaccess。即使我放了DirectoryIndex blablabla.php,浏览器仍然显示index.html.

如何解决这个问题?非常感谢。

您需要三样东西:

  1. <Directory>中,允许使用AllowOverride All访问.htaccess文件
  2. 使用Options FollowSymLinks授予mod_rewrite所需的权限
  3. 在.htaccess中,包括RewriteBase /test/