SOLVED Subdomain redirecting to www

Liam McArthur

Member
Jan 31, 2018
8
2
3
United Kingdom
cPanel Access Level
Root Administrator
I've purchased a new server and I'm currently in the process of migrating everything across. The main top-level websites are working fine but for some reason, none of my subdomains work because they're automatically trying to redirect to a www version of the subdomain which then breaks Chrome because of my HSTS rule.

Inside the httpd.conf file I found that my subdomain had a ServerAlias of www.sub.domain.com set up for it. I removed the www. from this and the subdomain has started working, but this file is automatically generated from WHM/cPanel so I fear this will get overwritten. Above this Virtual Host it says:

# To customize this VirtualHost use an include file at the following location
# Include "/etc/apache2/conf.d/userdata/std/2_4/username/sub.domain.com/*.conf"

But this location doesn't even exist. Any ideas?
 
Last edited:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,259
313
Houston
Hello @Liam McArthur

The serveralias is intended to be present all domains created will automatically get a serveralias for the www. subdomain. This will not cause the redirection you're seeing.

# To customize this VirtualHost use an include file at the following location
# Include "/etc/apache2/conf.d/userdata/std/2_4/username/sub.domain.com/*.conf"
This directory is only present if you've created it, if it's not present you've not added any includes for the VirtualHost.

If you're seeing a redirect happen globally for all your domains you might want to check .htaccess files and /etc/apache2/conf.d/includes/ for redirects to www.


Thanks!
 

Liam McArthur

Member
Jan 31, 2018
8
2
3
United Kingdom
cPanel Access Level
Root Administrator
I ended up removing the accounts completely, rebuilding Apache and manually adding the accounts/domains again. I believe a previously cancelled cPanel migration that crashed had caused some major problems throughout my installation but everything appears to be working perfectly again now.
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,259
313
Houston
Hi @Liam Venables

I'm glad to hear you were able to solve the problem and that everything is functioning as expected now. Thank you for updating us as to how you resolved the issue.


Thanks!