0

I have 50 sites with separate databases in drupal 7 set up and manage it in terminal on centos 7 and wondering if there is a way I can avoid having to have them all listed in custom conf file because they all have the same domain name just different subdomain. Using apache in /etc/httpd/conf.d/foo.conf .. Is there a way to make it so all 50 can be sorted in one bracket of code? Considering the only difference in the directory for each is numerical. So there is foo1.foo.com foo2.foo.com and so on. Instead of having this repeated fifty times in file where I have sites foo1 to foo50:

<VirtualHost *:80>
ServerName foo1.foo.com
ServerAlias www.foo1.foo.com
ServerAdmin [email protected]
DocumentRoot "/var/www/html/foo1.foo.com"
<Directory /var/www/html/xxx.x.xxx.xxx/foo1.foo.com>
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
3
  • conf file of what ? apache? nginx ?
    – Darek
    Commented Feb 21, 2015 at 9:00
  • sorry forgot to be clear- it is apache
    – cea
    Commented Feb 21, 2015 at 9:23
  • update your post and explain more. Commented Feb 21, 2015 at 13:09

1 Answer 1

0

I have not tested this, but you can trying doing something like this:

<VirtualHost *:80>
   ServerName *.foo.com
   VirtualDocumentRoot "/var/www/html/%0"
   <Directory /var/www/html/%0>
     AllowOverride All
     Allow from all
   </Directory>
</VirtualHost>

The %0 argument signifies the entire string from the address. An example of this would be, if someone went to foo1.foo.com => /var/www/foo1.foo.com. Alternatively, if someone tried foo2.foo.com, it would become /var/www/foo2.foo.com. Check the apache documentation for more directory name interpolation examples.

2
  • Thanks I have tested above but just renders all sites no show so I have read the link you gave from apache and it is not making sense to me yet but will persist.
    – cea
    Commented Feb 23, 2015 at 3:12
  • they are following naming convention but possess different directories so cannot be done.
    – cea
    Commented Feb 24, 2015 at 4:54

You must log in to answer this question.

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