Alias and RewriteBase

I have two Virtual Hosts configured on my Apache installation. The second Virtual Host has two Alias folders, pointed to the DocumentRoot folder of the first Virtual Host, which has a .htaccess files with some RewriteRules.

Whenever I send a request to the script (to rewrited rule URL) in the alias folder in the second Virtual Host, I am getting the 404 error. But When I send the request to the First Virtual Host with the same URL (without the alias prefix), it is working fine.

The .htaccess file in the Alias folder is not working when I send a request to the alias folder. If I use RewriteBase, then the requests sent to alias are working and requests sent to VHost 1 are failing.

Thanks in advance.

Aw, I HATE the RewriteBase as it’s only needed by mod_rewrite to UNDO the effects of a mod_alias redirection.

Okay, okay, I confess that I don’t understand why anyone would use it because I don’t fully understand what it does (and why it needs to be used) - to me, it merely confuses an already confusing situation with redirects. Having taken a look at what you’re doing with it, I believe that your approach is correct but … well, I need to look into it more and I’m away all this week so … er, sorry for the flip comment based on a bias of ignorance.



Any idea on setting the RewriteBase depending on Request URI?


It looks like you’ve got all your bases covered EXCEPT the leading / in the SetEnvIf statement.

For others:




Interesting concept - but the IfDefine’s vhost IS set the first time vhost1 is requested and I’m not sure about its longevity.



I tried the follwing configuration, which is not working…

RewriteBase /
SetEnvIf Request_URI ^/vhost1 vhost
<IfDefine vhost>
RewriteBase /vhost1

I tried

SetEnvIf Request_URI ^vhost1 vhost
also. This is also not working.