Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Configuring a local development linux box I'd like to have some sneaky Apache2 configuration which would do the following, when I request 'sub.domain.tld.local':

1.) Serve from: vhost/domain.tld/sub/htdocs/
2.) If there's no such directory, serve from: vhost/sub.domain.tld/htdocs/
3.) If there's no such directory, serve from: vhost/domain.tld/htdocs/

'.local' is just a static "suffix" which should not match any directory.

My current configuration looks like this:

<VirtualHost *:80>
    ServerAlias *.local
    UseCanonicalName Off
    VirtualDocumentRoot "/vagrant/host/%-2+/htdocs/"
    VirtualScriptAlias "/vagrant/host/%-2+/htdocs/"
</VirtualHost>

This works well for 2) or 3) but not in the manner of "crawling" the directory structure and falling back from 1) to 2) to 3). Preferably I'd like to only use the VirtualDocumentRoot directive somehow without any rewrite rules.

If it won't work without rewrites, I'm of course okay with that too.

Any idea how to solve that? Is it possible at all?

Thank you!

share|improve this question
    
I could make this work with a few RewriteRule directives (I do something similar on my servers) but I don't know hiw it can be done with just VirtualDocumentRoot –  Josh Mar 18 '13 at 13:56
    
Seems not doable with VirtualDocumentRoot alone, because it doesn't check existence of directories. What helps a little, and what I find quite interesting, is the fact, that ServerAlias works with multiple wildcards - like: "ServerAlias *.*.*.com" for example. :) –  Thasmo Mar 19 '13 at 23:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.