Skip to main content

How to include subdomain specific configuration files

Comments

3 comments

  • cPanelMichael
    Hello, You could try using a custom template with rules that add specific lines for certain domain names. There's an example of how this would work on the following post: Editing IfModule mod_include.c on virtualhost permanently Thank you.
    0
  • Zeddic
    I recently ran into this problem too and discovered that cpanel does support subdomain specific virtual host includes. However, the include line is not added to the httpd.conf file until after you create the subdomain specific include file and run the script to regenerate virtual hosts. The virtual host template file appears to do a directory existence check deciding to add the Include line. The steps I did: 1: Create Subdomain Specific .conf Files in:
    /etc/apache2/conf.d/userdata/ssl/2/username/sub.example.com/test.conf /etc/apache2/conf.d/userdata/std/2/username/sub.example.com/test.conf
    2: Regenerate Virtual Hosts
    /scripts/ensure_vhost_includes --user=username
    3: Find the new Includes in httpd.conf for just your subdomain:
    ServerName sub.example.com ServerAlias www.sub.example.com ... Include "/usr/local/apache/conf/userdata/std/2/username/*.conf" Include "/usr/local/apache/conf/userdata/std/2/username/sub.example.com/*.conf"
    0
  • Mani Rai
    I recently ran into this problem too and discovered that cpanel does support subdomain specific virtual host includes. However, the include line is not added to the httpd.conf file until after you create the subdomain specific include file and run the script to regenerate virtual hosts. The virtual host template file appears to do a directory existence check deciding to add the Include line. The steps I did: 1: Create Subdomain Specific .conf Files in:
    /etc/apache2/conf.d/userdata/ssl/2/username/sub.example.com/test.conf /etc/apache2/conf.d/userdata/std/2/username/sub.example.com/test.conf
    2: Regenerate Virtual Hosts
    /scripts/ensure_vhost_includes --user=username
    3: Find the new Includes in httpd.conf for just your subdomain:
    ServerName sub.example.com ServerAlias www.sub.example.com ... Include "/usr/local/apache/conf/userdata/std/2/username/*.conf" Include "/usr/local/apache/conf/userdata/std/2/username/sub.example.com/*.conf"

    It worked out quite well. Thanks a million Zeddic. I had so much trouble without this information and sorry for delayed response, I had very busy schedule to try it out.
    0

Please sign in to leave a comment.