SOLVED Redirect non-existing domains/sub-domains

Operating System & Version
CentOS v7.9.2009 STANDARD kvm
cPanel & WHM Version
108.0.14

gRobertsTVW

Member
Mar 15, 2022
9
1
3
UK
cPanel Access Level
Root Administrator
Hi all,

Is it possible to disable the "feature" within Apache that it displays the first VirtualHost when visiting a domain that is still pointing to the IP but not setup as an account?

It previously used to redirect to http://requested-domain.tld/cgi-sys/defaultwebpage.cgi but now it's loading the first VirtualHost without changing the URL.

This could potentially cause issues with indexing and duplicate content, so we're keen to prevent it on our servers.

I've had a look at the domain forwarding functionality but it's flagging that we don't have any IP's, despite there being one or more setup with multiple accounts attached.

I have also tried adding a VirtualHost entry (the commented out sections are various attempts):

Code:
<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>
to the following files:

/etc/apache2/conf.d/includes/pre_virtualhost_2.conf
/etc/apache2/conf.d/000-default.conf
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
17,470
2,843
363
cPanel Access Level
Root Administrator

gRobertsTVW

Member
Mar 15, 2022
9
1
3
UK
cPanel Access Level
Root Administrator