PROFESSIONAL WEB HOSTING SOLUTIONS
US 1-877-412-4678      International 1-317-961-1116

Why do undefined domains and subdomains load sites other than my own when I use external DNS? Print

  • 19

When you are using our DNS (i.e. ns1.mddservices.com, ns2.mddservices.com, and ns3.mddservices.com) you should not face this issue. There will be no DNS records for any subdomains that are not added to your cPanel (unless you manually create them) and, as such, they will not resolve to any specific IP address. This issue most commonly affects those who use third party DNS when they configure a DNS entry to point to their IP but do not configure their cPanel to handle that subdomain or domain.

The way Apache and LiteSpeed work, is called "Virtual Hosts". In the configuration file for the server there is a virtual host for each domain, subdomain, etc. When a request comes in to load a site, the web server checks the configuration file and loads the files from the appropriate location based upon the information contained in the matching virtual host. This works great when you're loading a subdomain that you've created, but can cause some confusion if you load something else.

Let's say for example that you have "domain.com" as your primary domain and you've created "videos.domain.com" in your cPanel. When accessing either of these domains you will see the appropriate content. If you were, however, to try visiting an unconfigured subdomain such as "video.domain.com" [notice the missing S on video] the server will search the configuration file for the matching virtual host and since one does not exist, it will not find an exact match.

The server will then ignore the domain, as there was no match, and will find the next closest virtual host by IP address and port. This, more often than not, will result in somebody else's site loading instead of your own unless your virtual host happens to be listed first for the IP address in the configuration file.

There are two simple solutions, with the first being ideal:

  1. Simply do not create any DNS entries for domains or subdomains that you've not added to your cPanel.
  2. Create a '*' subdomain which will cause any non-configured subdomain to match, allowing you to create redirections if needed using mod_rewrite.
Sometimes, however, other customers or ex-customers will point domains to the same IP as your account - either because their domain used to be hosted there or simply by mistake and that will cause your content to load under their domain. In this situation, we suggest using mod_rewrite to redirect any domain other than your own back to your own domain.
 
The rule would look something like this (again, this is an example and would need modified for your purposes):
 
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ # This line checks to see if the domain is currently "www.domain.com".
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] # This line re-directs to "www.domain.com" only if the condition above is not met.

Was this answer helpful?

« Back