Apache : How to Use Rewrite Engine Inside Alias
-
28-04-2021 - |
Question
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.
La solution
You need three things:
- Inside
<Directory>
, allow .htaccess files withAllowOverride All
. - Give the required permissions of mod_rewrite with
Options FollowSymLinks
. - Inside the .htaccess, include
RewriteBase /test/
.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow