Here is a scenario of what I am trying to do.
Folder A has folders B and C.
Folder B has D, E and index.html.
Folder C has index.html
I declared folder B as my DocumentRoot. Declared an Alias for Folder C to point it to /A/C. I want apache to serve index.html in B for any requests coming in to B (/B/D or /B/E or /B/** should return /B/index.html)
Here is the sample virtual host config
<VirtualHost *:8080>
...
DocumentRoot "/usr/local/var/www/A/B"
Alias "/C" "/usr/local/var/www/A/C"
<Directory "/usr/local/var/www/A">
....
</Directory>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^/B/.+ /B/ [PT]
....
</VirtualHost>
With this configuration, I am running in to redirect loop.
2
Answers
the original request path,"/test/c/1", will match with "^/test/[abc].+$", matched successfully, so the request path change from "test/c/1" to "/test/". but due to the PT flag, cause the "/test/" routed back as if "/test/" is a newly come in, so "/test/" will match with "^/test/[abc].+$" again, but this time match failed, so you got 404.
change the flag from PT to L, the behavior is while the original request path,"/test/c/1", match with "^/test/[abc].+$" successfully, the redirected path "/path" will be the final path. apache get the resource related "/test/" and response to the client.
You may try this rule:
Then: