Reputation:
I would like to create an alias for a directory, but I would like to do this in a separate configuration file than where I have defined my VirtualHost
block.
Example:
default.conf
<VirtualHost *:80>
ServerName myserver.example.com
DocumentRoot /path/to/my/site
...
</VirtualHost>
In a separate file: alias.conf
<VirtualHost *:80>
ServerName myserver.example.com
Alias /path/to/directory/in/another/location
</VirtualHost>
I do not want to put this alias in my primary configuration file. When I have two VirtualHost
blocks with the same ServerName
apache does not start and produces an error.
Is this possible?
Upvotes: 1
Views: 1329
Reputation: 8591
Use Include
to do that.
Ex:
httpd.conf
----------
<VirtualHost *:80>
... SOME CONFIGURATION ...
Include conf/extra_config.conf
</VirtualHost>
extra_config.conf
-----------------
Alias /alias/ /somewhere
Since extra_config.conf was Included in the context of the VirtualHost, it will apply to this one. You cannot have two times the same VirtualHost with the same ServerName anywhere.
Upvotes: 1