Is it possible to configure Apache to have different virtual hosts listening on the same IP address, same port, such that certain paths (not the full domain, just the local path) will direct to one virtual host, and others will default to the other?
For example:
#All requests to www.mysite.com/special-url go here
<VirtualHost /special-url:80>
DefaultType application/x-httpd-php
ServerName server1
Document Root "/home/me/server1"
<Directory "/home/me/server1">
AllowOverride None
Order allow, deny
allow from all
</Directory>
</VirtualHost>
#All other requests go here
<VirtualHost *:80>
DefaultType application/x-httpd-php
ServerName server1
Document Root "/home/me/server2"
<Directory "/home/me/server2">
AllowOverride None
Order allow, deny
allow from all
</Directory>
</VirtualHost>
This server configuration doesn't work, and neither does adding wildcard combinations to the first VirtualHost
tag (e.g. VirtualHost */special-url:80
). Instead, when I run this, Apache directs requests to /special-url
to /home/me/server1
. But if I look for /foo
it will still look for that in server1
and return 404
even if there is a directory called foo
in /home/me/server2
.
Is there any way to have one VirtualHost just for certain URLs, and another VirtualHost for all other URLs?