Modify Apache Virtual Hosts with Include Files
Last modified: July 11, 2022
You can use the command line interface to add include files that modify the content of the virtual hosts in your Apache configuration. You may wish to do this to modify the configuration of an individual domain, or a specific user’s domains.
You must create the directories and the include files for this type of configuration. For information on the directives that you can add to the virtual hosts in your Apache configuration, read Apache’s documentation.
- Includes are the last directives in each virtual host. An include file’s contents override any value that exists in the primary configuration file.
- If you use an include that requires a specific Apache version, and you change to a different Apache version, the Apache configuration will ignore the include file.
Include file structure
You must use the following directory structure to create an include file for an individual domain:
In the following examples:
userwith the account’s username.
domainwith the domain name.
includename.confwith the filename that you wish to include.
Apply to an individual virtual host
- With SSL -
- Without SSL -
Apply to all virtual hosts on the system
- Include files that do not designate a specific Apache version may not migrate properly to future versions of Apache.
- Include files with local overrides cause the system to permanently disable the Force HTTPS Redirects option in cPanel’s Domains interface (cPanel » Home » Domains » Domains).
With and without SSL —
Apply to all virtual hosts that a user owns
- With SSL —
- Without SSL —
After you create or edit an Apache include
userdata file, you must rebuild the
httpd.conf file and restart Apache for the changes to take effect.
To rebuild the
httpd.conf file, run the following script:
To restart Apache, run the following script: