0

I am trying to add virtual hosts to my Apache, but I am trying to do it in a specific way of which I don't know if it is possible.

I currently have it like this:

<VirtualHost *:80>
    ServerName til.local
    DocumentRoot "C:/xampp/htdocs/til"
    <Directory "C:/xampp/htdocs/til">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Where "til" is the name of the folder AND of the 'domain name'.

I want to set something up once so I don't need to look at it anymore afterwards, even when adding new folders to the htdocs folder. I am going to create a lot of different domains in a short period of time so I don't want to go to the apache settings every single time I add a virtual host. Is it possible to set something up that haves all folders in the htdocs automatically be a domain name like this? So if I put abc as a folder, it uses "abc.local" and the folder "htdocs/abc"?

1 Answer 1

1

You should take a look at mod_vhost_alias documentation.

http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html

Configuration could look something like:

<VirtualHost *:80>
    ServerName *
    VirtualDocumentRoot "C:/xampp/htdocs/%0"
    <DirectoryMatch "C:/xampp/htdocs/*">
        Options FollowSymLinks
        AllowOverride All

        Order allow,deny
        Allow from all
    </DirectoryMatch>
</VirtualHost>

Note that %0 stands for full ServerName (in your case til.local). If you read the docs you'll probably figure it out how to set it up the way you want.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .