Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I had a problem of changing an IP address of just one of the few addon domains on a cPanel/WHM account, but I managed to find a solution (by manually editing A records in DNS zones of the main account and the addon domain, and changing the IP in /var/cpanel/userdata/username/addon.domain.com).

However, this addon domain (example.com) also had a subdomain attached to it (sub.example.com), so I replaced the IP in the A records for it too, and I also changed the IP via SSH in the above mentioned path.

Now both example.com and sub.example.com are correctly resolving to the new dedicated IP and that's okay. But when I type this IP address in the browser, it loads the sub.example.com website instead of the main example.com website.

I have no clue as to why is this happening. How do I change the main (primary, default) website of a dedicated IP address?

share|improve this question

migrated from superuser.com Sep 19 '12 at 0:20

This question came from our site for computer enthusiasts and power users.

1 Answer 1

up vote 1 down vote accepted

You have two virtual hosts on the same address, so Apache (assuming that you use Apache) considers the virtual host that is loaded first the primary one. Any request that does not match a ServerName directive will go to that virtual host.

You need to change the order in which the two VirtualHost sections are loaded. In Apache you'd switch the sections if they're in the same file, or (if they're in separate files) you'd name the files something like 000-addon.com and sub.addon.com, so that the addon.com configuration would be listed first, and thus loaded first.

The above would require shell access, though. I'm not familiar with CPanel, so I can't tell you how to do this change using the CPanel interface.

share|improve this answer
    
Yes, the server is running Apache and also CentOS, so I have all VirtualHost sections in one httpd.conf file. And, indeed, the section for sub.addon.com was listed before the section for addon.com. But, when I changed the order of the sections and ran /scripts/rebuildhttpdconf, the httpd.conf file reverted to what it was before the change (cPanel generated). I also tried /usr/local/cpanel/bin/apache_conf_distiller --update before rebuilding, but it didn't work. This is a cPanel "EasyApache" issue. If you're not familiar with cPanel, you still helped me a lot, and thanks for the answer! –  Anderson Sep 18 '12 at 23:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.