We have a vhost conf file which is a catch-all in a multi-tenant scenario, however there's a requirement for one of our clients to have a specific alias
declaration which is currently defined like so...
Alias /special "/srv/application/public/example/special"
Currently this means that EVERY single client / domain in the system would be caught and forced to serve /special/
which is obviously a problem.
How can I limit the scope of this Alias
declaration so that it is only applied when the requested domain matches example.com
or www.example.com
?
FYI, we're moving from Apache 2.2 to 2.4 shortly, if there are any differences in the particular case, please point them out. Thanks!
EDIT I should point out we're limited in this instance by middle ware and must keep everything in a single vhost declaration.
The most straightforward way is to create a separate, non-default virtual host declaration just for that domain:
The only disadvantage is that you'll then need to maintain the same
# other default directives
in both the example.com and default virtual hosts. A good way to do that is to put them all into a file, andInclude
that file in both virtual host declarations.Alternatively, you can keep just one virtual host declaration and add a RewriteRule:
Be sure to consider which method will be more sustainable when you add more exceptions in the future, as you surely will.
You should put the alias directive within the VirtualHost definition for example.com
large vhost files make managing very difficult, create an individual file for each tenant and INCLUDE it in the vhost file. this can be done live and have apache reload the configs when its done. this way you can support multiple domains per tenant and makes it easier to make changes like Andrew suggested above.