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.

I'm trying to set up a dynamic virtual host in apache with a directory alias pointing to a difirent path for every domain.

Here's what I'm trying to achive.

Say I have 2 domains:

* www.domain1.com
* www.domein2.com

I want both to point to the same index.php file (C:/cms/index.php). Now the hard part ... I want directories or certain file types to point to a diffirent path for each domain.

Example:

* www.domain1.com/layout -> C:/store/www.domain1.com/layout
* www.domain2.com/layout -> C:/store/www.domain2.com/layout
* www.domain1.com/image.png -> C:/store/www.domain1.com/image.png
* www.domain2.com/image.png -> C:/store/www.domain2.com/image.png

However the admin directory should point to the same path again for all sites

* www.domain1.com/admin -> C:/cms/admin
* www.domain2.com/admin -> C:/cms/admin

Is there a way to achieve this kind of behaviour in apache 2.2 without having to create a virtualhost entry for each new domain?

share|improve this question

2 Answers 2

Try:

DocumentRoot "C:/store/"

<Directory />
    ....
    RewriteEngine on
    RewriteCond %{REMOTE_HOST}  ^www.domain1.com$
    RewriteRule (.*)$ /www.domain1.com/$1 [L]

    RewriteCond %{REMOTE_HOST}  ^www.domain2.com$
    RewriteRule (.*)$ /www.domain1.com/$1 [L]
</Directory> 

Alias /admin C:\cms\admin

<Directory "C:\cms\admin">
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory> 
share|improve this answer

you can try to use VirtualDocumentRoot, for more information read the apache doc and examples

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.