subdomain redirecting to root domain

actived

Well-Known Member
Mar 30, 2012
51
0
56
cPanel Access Level
Website Owner
All our subdomains *.domain.com are redirecting to domain.com/index.php.

Checked htaccess files in all subdomains for such a rule, no such.
It could be that the third-party script we use does something like this due to some misconfiguration, but if that was the case, new blank subdomains wouldnt redirect to root.

This among other things, is what the httpd.conf has:
Code:
<VirtualHost x.x.x.x:80>
   ServerName domain.com
   ServerAlias [url]www.beta.domain.com[/url] [url]www.test.domain.com[/url] [url]www.domain.com[/url] test.domain.com beta.domain.com
   DocumentRoot /home/user1/public_html
   ServerAdmin [email][email protected][/email]
1.
Does this explain anything - maybe since all subdomains point to the root public_html, it works that way?
If that's what is wrong, then how do I fix it - given that editing the httpd.conf file is not to be done?

The beta subdomain was merely pointing to the directory /home/user1/public_html/beta/
Is this a case of "addon" subdomain being mapped incorrectly as a "user" subdomain?

2.
When i tried deleting and re-creating the beta subdomain to point to /home/user1/public_html/beta from CPanelX - deletion looked successful at first,
but on attempting to create it again, it said "domainadmin-exists: beta.domain.com"

3.
I recently did a rebuild of EasyApache to enable mod_security, mod_deflate, mod_usertrack and disable frontpage extensions.

Is there some post-build process needed to reconfigure Apache ?

Related question: Is there a simple tutorial explaining virtual hosts + subdomains ?
The Apache manual isn't the easiest and my Google skills are failing me on this one.

Thanks in advance,
Dave
 

storminternet

Well-Known Member
Nov 2, 2011
460
0
66
cPanel Access Level
Root Administrator
Please look at the ServerAlias entry you had added in virtualhost of the domain. All subdomains are added as serveralias and that's the reason they are using document root as /home/user1/public_html.

ServerAlias www.beta.domain.com www.test.domain.com www.domain.com test.domain.com beta.domain.com
You need to remove subdomains from serveralias first and then need to readd it again from cPanel.
 

actived

Well-Known Member
Mar 30, 2012
51
0
56
cPanel Access Level
Website Owner
Thanks for a quick reply!

I know editing of httpd.conf isnt supposed to be done. Upon looking around I found this:
http://forums.cpanel.net/f5/remove-serveralias-virtualhost-170106.html
Is this the way to remove the serveraliases?
That one tells about this path:
Code:
/var/cpanel/userdata/username/subdomain.domain.com
This one: Daily Tech Tip: Removing a stray domain from a cPanel account « Brandon's Blog
shows a different path:
Code:
/var/cpanel/users/USERNAMEHERE
So which one?
Thanks again,
Dave.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
If you aren't going to be removing and readding the subdomains to point to the right location via cPanel, then you would want to edit /var/cpanel/userdata/username/subdomain.domain.com file (and maindomain.com file if they are also in there) to have the right path to the subdomain. After revising the file, you'd want to run the following commands:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak120502
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
At that point, check /usr/local/apache/conf/httpd.conf has the right entries for the subdomains. If it does, then check them in a proxy such as proxify.net or kproxy.com as you might be cached to the old location.
 

actived

Well-Known Member
Mar 30, 2012
51
0
56
cPanel Access Level
Website Owner
Hi,
I tried out all the above steps (exact order) but the ServerAlias line in /usr/local/apache/conf/httpd.conf is the same - that is the test and beta subdomains are configured as aliases of the main domain.

However, I added another test domain, say test2, from cPanel X, which is working perfectly so far.

I have saved the current working httpd.conf. So if anything breaks later on, I hope I can just replace this httd.conf into the proper directory ( is it /etc/httpd/conf/ or /usr/local/apache/conf/ ? ) and get it to work.

We dont really need any more domains or subdomains if a test domain works well, so I'm not likely to do any more changes to domain configuration, even indirectly. Hopefully!

Obviously this is a dirty hack and far from the solution, but at least it will keep the test site running for work.

Thanks again for all the replies.
Dave
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
What precisely did you try? Please post what you did exactly in what file (the exact lines revised and what you changed them too) along with what is not working. Details are extremely important.