1

Not sure when but WHM/cPanel and/or Apache have changed how they handle requests for domains that do not exist.

Previously it would redirect to http://requested-domain.tld/cgi-sys/defaultwebpage.cgi however it will now simply show the content of the first domain listed in the virtual hosts without changing the domain.

I've tried adding variations of the following to:

  • /etc/apache2/conf.d/includes/pre_virtualhost_2.conf
  • /etc/apache2/conf.d/000-default.conf
<VirtualHost *>
  ServerName subdomain.server-domain.tld
  RedirectPermanent / /cgi-sys/defaultwebpage.cgi
  #RewriteEngine on
  #RewriteCond %{HTTPS} on
  #RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  #RewriteCond %{HTTPS} off
  #RewriteRule ^/(.*)$ /cgi-sys/defaultwebpage.cgi [L,R=302]
</VirtualHost>

Neither redirect the request to http://requested-domain.tld/cgi-sys/defaultwebpage.cgi

Does anyone have any suggestions?

Gavin
  • 121
  • 4

1 Answers1

1

Adding the following to /etc/apache2/conf.d/includes/pre_virtualhost_global.conf resolved the issue:

<VirtualHost xxx.xxx.xxx.xxx:80>
    ServerName xxx.xxx.xxx.xxx
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx:443> ServerName xxx.xxx.xxx.xxx DocumentRoot /var/www/html <IfModule suphp_module> suPHP_UserGroup nobody nobody </IfModule> <Directory "/var/www/html"> AllowOverride All </Directory> <IfModule ssl_module> SSLEngine on

    SSLCertificateFile /var/cpanel/ssl/cpanel/cpanel.pem
    SSLCertificateKeyFile /var/cpanel/ssl/cpanel/cpanel.pem
    SSLCertificateChainFile /var/cpanel/ssl/cpanel/cpanel.pem
    SSLUseStapling Off
&lt;/IfModule&gt;
&lt;IfModule security2_module&gt;
    SecRuleEngine On
&lt;/IfModule&gt;

</VirtualHost>

For servers with multiple IP addresses, you are required to replicate for each IP.

https://support.cpanel.net/hc/en-us/articles/360061002473-How-do-I-set-a-default-VirtualHost-for-each-IP-address-

Gavin
  • 121
  • 4