Subdomains and cPanel
A Guide to Using MediaWiki in a Hosted Environment
An instructional website by the developer of mh370wiki.net - a MediaWiki site about Malaysia Airlines Flight MH370.
Domains, Subdomains and cPanel
The domain name registered for a website forms part of the URL used by a web browser. The domain portion of a URL is used to query DNS servers so that the browser can direct a query for a webpage to a specific IP Address.
However, apart from an insufficient number of IP Version 4 addresses, the hosting service providers share each IP address among several user accounts. At the very least if you have an account with several websites they will all share the same IP address.
The Main Domain
When you establish an account with a hosting service provider you usually register a domain name for the first website, or supply a domain name which may have been registered separately.
This becomes your Main Domain.
For purposes of this explanation, assume that the main domain is MyWebsite.wiki. The URL would therefore be https://www.mywebsite.wiki
Websites are usually located in a subdirectory of your /home account, at /home/public_html. So the main domain may point to /home/public_html/MyWebsite.
As recommended, your MediaWiki installation will be in a subdirectory /w, or /home/public_html/MyWebsite/w
A BIG problem results if the hosting provider did not allocate subdirectory in /public_html because a normal cPanel user does not have sufficient privileges to create a new folder for their main domain.
This BIG problem becomes apparent when want to add separate websites after you register and add additional domains or if you create subdomains to use for separate websites. A solution is a complex system of .htaccess files, not covered in this article.
Addon Domains
If you have additional registered domains they are added via cPanel --> Domains --> Domains which opens a list of domains.
A Subdomain can be added as described in the article Create a Subdomain.
For this example we will begin with a subdomain for mywebsite.wiki which we will call ships, so the domain will be listed as ships.mywebsite.wiki.
The associated website could be located at /public_html/Ships and MediaWiki would be installed in /public_html/Ships/w
But the website ships.mywebsite.wiki shares the same IP address as www.mywebsite.wiki and mywebsite.wiki.
A set of DNS records exists for the main domain mywebsite.wiki and DNS records are created for ships.mywebsite.wiki and added to the records for the domain mywebsite.wiki.
The same process occurs if you add additional domains. For example if you register shipsandplanes.wiki and create a website for Ships and Planes it will share the same IP address as the main domain and any other subdomains of the main domain.
DNS records for the new domain shipsandplanes.wiki will be created AND additional records will be added to the mywebsite.wiki DNS record.
cPanel will treat the new domain as though it is a subdomain of your main domain and creates records for shipsandplanes.wiki.mywebsite.wiki.
The DNS records are visible via cPanel -->Domains --> Zone Editor.
The 'subdomains' are actually visible via cPanel -->Domains but not shown by default. Click on the toothed wheel symbol on the menu bar - this setting toggles 'Show Associated Subdomains' and 'Hide Associated Subdomains'.
The subdomains that this applies to are these 'extra' subdomains.
Related Issues
All of the domain.maindomain zone records are valid. That means you can legitimately put this URL in a browser https://shipsandplanes.wiki.mywebsite.wiki and it will load your website shipsandplanes.wiki
Some browsers are configured to display a search term as well as, or instead of, the page address. So although a webpage request has been correctly resolved to the actual domain name, the browser may display the longer url which includes the main domain.
Can this be avoided or prevented? Unfortunately, no.
Actually, the situation becomes more complex if the number of registered domains is increased, and worse if there are redirects which make it difficult to unravel what is happening.
Articles which relate to Subdomains and cPanel
Articles which relate to Subdomains and cPanel are included in Category:Domains.
The CategoryTree Extension enables a listing of relevant sub-categories and pages:-
Links
- Create a New Domain
- https://docs.cpanel.net/cpanel/domains/domains/create-a-new-domain/
cPanel calls these Addon Domains - How Your Server Handles Domains and Virtual Hosts
- https://docs.cpanel.net/knowledge-base/cpanel-product/how-your-server-handles-domains-and-virtual-hosts/
cPanel documentation which covers the content of this article, explained their way - Basic WebHost Manager Setup
- https://docs.cpanel.net/whm/server-configuration/basic-webhost-manager-setup/
This page describes what is set up for a new account holder, by the Service Provider 'behind the scenes'.