views:

26

answers:

1

I have a Windows/Apache/PHP environment set up to imitate a shared hosting account but cannot get mod_alias and mod_rewrite to play nicely with one another. Both are definitely enabled at the server level and on a per-site basis.

I have d:\web\public_html\ set up as DocumentRoot. But generally speaking it will be empty.

I have d:\web\sites\ which is where I'll be storing my sites and pointing to using Alias and it has the following directory structure beneath it:

d:\web\sites\alfa
d:\web\sites\alfa\public_html
d:\web\sites\bravo
d:\web\sites\bravo\public_html

I have aliases set up as follows: (and they definitely work!)

Alias /alfa d:/web/sites/alfa/public_html
<Directory "D:\web\sites\alfa\public_html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

The public_html folder(s) are where my per-site .htaccess files are stored and they definitely have mod_rewrite enabled but won't work correctly.

So far I have come unstuck with what RewriteBase should be. I've tried /, /alfa, /alfa/ and alfa/. I've even tried d:\web\sites\alfa\public_html, d:/web/sites/alfa/public_html, d:\web\sites\alfa and d:/web/sites/alfa to no avail!

Is this even possible? If so, what am I doing wrong?

I'd obviously like to keep my Alias directives centralised and by RewriteRules in per-site .htaccess files.

+2  A: 

You are using the

AllowOverride None

directive and thus disabling any .htaccess files in the aliased directory. Remove that, and it should work.

/ should work for RewriteBase.

Pekka
Straight from my httpd.conf: <Directory "D:/web/public_html"> Options Indexes FollowSymLinks AllowOverride All Order allow,deny Allow from all</Directory>
Matt
@Matt so the code you are quoting in your question is not the correct one?
Pekka
Thankyou!! I have my aliases in a seperate file to httpd.conf and I hadn't spotted it in there! Thank you so much!
Matt
For reference though, I'm using `RewriteBase /alfa` so that my rules don't have to be prefixed with `/alfa`. Is that the correct usage/purpose of `RewriteBase`?
Matt
@Matt ah, I overlooked that you are in a subdirectory. Yes, that *should* work (although `RewriteBase`'s behaviour has always been a bit of a mystery to me, in some situations working for me, and sometimes not... Maybe I'll ask about it on SO some time.)
Pekka