Add custom Apache rules in cPanel

Add custom Apache rules in cPanel

You can customize Apache (2.4) virtual hosts with Include Files, by creating new include.conf file for that user or for all vhosts on your server.

💡 In the following code snippets make sure to replace:

  • <user> with the cpanel account’s username
  • <domain> with the domain name
  • <include.conf> with desired filename, or leave as include.conf

Scheme for an individual virtual host

SSL:

/etc/apache2/conf.d/userdata/ssl/2_4/<user>/<domain>/include.conf

Non-SSL:

/etc/apache2/conf.d/userdata/std/2_4/<user>/<domain>/include.conf

Scheme for all virtual hosts

SSL:

etc/apache2/conf.d/userdata/ssl/2_4/include.conf

Non-SSL

/etc/apache2/conf.d/userdata/std/2_4/include.conf

Scheme for all virtual hosts that the user owns

SSL:

/etc/apache2/conf.d/userdata/ssl/2_4/<user>/include.conf

Non-SSL:

/etc/apache2/conf.d/userdata/std/2_4/<user>/include.conf

After creating new or editing existing include userdata file, you must rebuild the httpd.conf file and restart Apache for the changes to take effect:

Rebuild httpd.conf:

scripts/rebuildhttpdconf

Restart Apache:

scripts/restartsrv_httpd
whoami
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.