exiang
exiang

Reputation: 559

Apache mass virtual host dynamically

I have an Apache server that takes in all sort of domain that point to it, for example:

Then, it will resolve these domain name to a sub folder, for example

I can do it using virtual host but i will need to manually add the entries and restart server each time there are changes.

Is there any way to do the setting dynamically?

Upvotes: 0

Views: 1981

Answers (1)

Andrew J. Johnson
Andrew J. Johnson

Reputation: 937

The section "Dynamic Virtual Hosts with mod_vhost_alias" in the Dynamically Configured Mass Virtual Hosting page of the Apache docs helped me out with this. The only part I had to add to my httpd.conf file was the following:

VirtualDocumentRoot /www/hosts/%0/docs
VirtualScriptAlias  /www/hosts/%0/cgi-bin

The %0 is the variable that takes whatever domain is being accessed and points it to the folder in /www/hosts/ with the same name. /docs is the folder where you put your public HTML files for each site, a different one for each. You can edit those to what you want.

Hope that helps!

Upvotes: 2

Related Questions