Subdomains always redirecting to www.subdomain.domain.com

mofolo

Member
Jan 26, 2012
18
0
51
cPanel Access Level
Website Owner
Hello,

I have this current set up with my website:

www.domain.com
subdomain.domain.com

However, when I create subdomain.domain.com it will always redirect to www.subdomain.domain.com

I have found a way to temporarily fix this. First; I remove the DNS A entry which has www.subdomain.
Next, I go into the http.conf and change ServerAlias from www.subdomain.domain.com to subdomain.domain.com
and also set UseCanonicalName to Off

However, every time I rebuild the httpd.conf file either by changing the settings or easyApache, the problem re-occurs.
The ServerAlias changes back to www.subdomain.domain.com.
(I have edited /var/cpanel/userdata/username/subdomain, but the problem still happens)

Is there a permanent fix that makes Cpanel not redirect to www.subdomain?
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
cPanel would not automatically redirect to the subdomain www version unless there is an entry in the main domain or subdomain .htaccess file for non-www to www redirection. Please check /home/username/public_html/.htaccess for any redirects on the account.

As for the /var/cpanel/userdata/username/subdomain.domain.com entries, if you are revising those, I've never heard of those files re-adding the www subdomain as a serveralias at that point or rechanging the canonical setting. They should stick if you revise the entries in that file and then run "/scripts/rebuildhttpdconf" afterward to check /usr/local/apache/conf/httpd.conf settings.
 

mofolo

Member
Jan 26, 2012
18
0
51
cPanel Access Level
Website Owner
Hi Tristan,

Thanks for the reply.

You were very right - it was being redirected by the .htaccess. It has been fixed now, Thanks!