opentoe

Active Member
Feb 6, 2013
40
0
56
cPanel Access Level
Website Owner
When I enter whn.mydomain.com it opens up my WHM login. I don't even have to use a port number or anything. When I ping whm.mydomain.com is comes back with the correct hosts IP address. What confuses the HECK out of me how does the system/network know to bring up the WHM login for me? An example is if enter ftp.mydomain.com of course it won't bring up the WHM login for me, but it does resolve to the SAME IP address. I'm confused as to how the system knows what to do. Like webmail.mydomain.com and all that. It all resolves to the same IP address. Thanks.
 

Jeff Shotnik

Well-Known Member
Oct 10, 2012
61
0
6
Denver, Colorado, United States
cPanel Access Level
DataCenter Provider
cPanel does it with rewrite rules in the httpd.conf:

RewriteCond %{HTTP_HOST} ^cpanel\.
RewriteCond %{HTTPS} on
RewriteRule ^/(.*) https://127.0.0.1:2083/$1 [P]
RewriteCond %{HTTP_HOST} ^webmail\.
RewriteCond %{HTTPS} on
RewriteRule ^/(.*) https://127.0.0.1:2096/$1 [P]
RewriteCond %{HTTP_HOST} ^whm\.
RewriteCond %{HTTPS} on
RewriteRule ^/(.*) https://127.0.0.1:2087/$1 [P]
RewriteCond %{HTTP_HOST} ^webdisk\.
RewriteCond %{HTTPS} on
RewriteRule ^/(.*) https://127.0.0.1:2078/$1 [P]
RewriteCond %{HTTP_HOST} ^cpanel\.
RewriteRule ^/(.*) http://127.0.0.1:2082/$1 [P]
RewriteCond %{HTTP_HOST} ^webmail\.
RewriteRule ^/(.*) http://127.0.0.1:2095/$1 [P]
RewriteCond %{HTTP_HOST} ^whm\.
RewriteRule ^/(.*) http://127.0.0.1:2086/$1 [P]
RewriteCond %{HTTP_HOST} ^webdisk\.
RewriteRule ^/(.*) http://127.0.0.1:2077/$1 [P]
RewriteCond %{HTTP_HOST} ^autodiscover\.
RewriteRule ^[^?]*(\?.*)? http://127.0.0.1/cgi-sys/autodiscover.cgi [P]
RewriteCond %{HTTP_HOST} ^autoconfig\.
RewriteRule ^[^?]*(\?.*)? http://127.0.0.1/cgi-sys/autoconfig.cgi [P]