How does Apache know where to direct web requests?

advantec

Registered
Oct 1, 2013
0
0
0
cPanel Access Level
Reseller Owner
I'm new to cPanel, and Linux based hosting. Doing pretty good, but I can't figure this thing out:

I have mydomain.com as my primary domain; new.mydomain.com points to my primary IP. I also have an A record for x.mydomain.com pointing to my shared IP (which is different from my primary IP) - I (want to) use it for new website development, I can tell clients to go to x.mydomain.com/~whatever, and they can see what I'm working on. That works fine, except, if you go to x.mydomain.com - you will get, by default the same content as x.mydomain.com/~client2 ...

(I should also note - if I browse to new.mydomain.com I get the "Default Website Page" that comes with cPanel - which would be expected)

I could probably fix it, by deleting the A record, then creating a CNAME to point to a specific folder, but I don't really want to do that. Mainly, I want to understand how it works...

I tried to publish a website in the mydomain.com section of cPanel - I thought that would give Apache something to point to, but that didn't make a difference.

How does Apache know where to point web requests? If there's something wrong, what can I edit to fix it?
Also, (out of curiousity) how can a web request for the primary/root account by default point to an entirely different account's website (in this case, that of client2)?

Thanks to all who reply!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello :)

Are you sure the shared IP address is not a dedicated IP or the only IP address assigned to an account? It's likely configured as a dedicated IP address. Thus, any attempts to access it directly, or to access websites pointing to it with no Virtual Host will point to the default cPanel page. Rather than setting up a manual "A" record for your subdomains, have you considered creating them as their own accounts or as subdomains under an existing account? You may also want to try rebuilding the Apache configuration file via:

Code:
/scripts/rebuildhttpdconf
Thank you.