Apache : How to Use Rewrite Engine Inside Alias

我们两清 提交于 2019-12-19 09:16:12

问题


I have this alias configuration:

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

Then inside D:/WWW/Test/ directory, I put .htaccess with the following configuration:

<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteRule ^([^.]*\.css)$ resources/$1 [L,NC]
</IfModule>

I just want to redirect all request from localhost/test/css/* to localhost/test/resources/css/*.

But it seems that the .htaccess is ignored. Even if I put DirectoryIndex blablabla.php , browser still displays index.html.

How to solve this? Thank you.


回答1:


You need three things:

  1. Inside <Directory>, allow .htaccess files with AllowOverride All.
  2. Give the required permissions of mod_rewrite with Options FollowSymLinks.
  3. Inside the .htaccess, include RewriteBase /test/.


来源:https://stackoverflow.com/questions/9251305/apache-how-to-use-rewrite-engine-inside-alias

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!