I Need To Make A Change With My IT Support! Call (225) 706-8414

Adding Additional VirtualHost Configurations to WHM CPanel Sites

You have a website managed through WHM CPanel but need to add special configuration directives to the virtual host configuration (e.g. mod_rewrite rules that don’t work in an .htaccess file).


You need to create a directory for your configuration overrides via the Linux command-line.

  1. Logon to the host server with root privileges (using sudo as a normal user will work just fine)
  2. Run the following command, where domain.com is the domain to which you want to add the new virtual host configuration
    # /scripts/ensure_vhost_includes –domain=domain.com
    Note: this command will restart the Apache webserver
  3. If you search /etc/httpd/conf/httpd.conf for the domain name, you should see a line like the following:
    # grep “Include.*domain.com
    Include “/usr/local/apache/conf/userdata/std/2/
  4. Create the target directory, if doesn’t already exist:
    # mkdir -p “/usr/local/apache/conf/userdata/std/2/username/domain.com/”
  5. Create a new file in that directory; the name doesn’t really matter so long it ends in .conf. For the mod_rewrite example mentioned above, you might use the following:
    # touch “/usr/local/apache/conf/userdata/std/2/username/domain.com/rewrite.conf”
  6. Edit the new file and enter your directives in the file.
    # vim “/usr/local/apache/conf/userdata/std/2/username/domain.com/rewrite.conf”
  7. Restart Apache
    # service httpd restart
  8. Refresh the site in your browser and confirm everything is working as expected. Remember: any incorrect configuration directives in your new file may prevent Apache from restarting. If the site doesn’t load, you can change the extension on your new file and restart Apache again to get it back to the previous working state while you review your changes.


Concerned About Cyber Attacks?


Want to Migrate to the Cloud?

Office 365

Ready to Experience Microsoft Office 365?

Want the latest IT news directly in your inbox? Subscribe now!