Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Subdomain redirecting to www

Discussion in 'General Discussion' started by Liam McArthur, May 21, 2018.

  1. Liam McArthur

    Liam McArthur Member

    Joined:
    Jan 31, 2018
    Messages:
    8
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    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?
     
    #1 Liam McArthur, May 21, 2018
    Last edited: May 21, 2018
  2. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,042
    Likes Received:
    212
    Trophy Points:
    173
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    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.

    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!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Liam McArthur

    Liam McArthur Member

    Joined:
    Jan 31, 2018
    Messages:
    8
    Likes Received:
    2
    Trophy Points:
    3
    Location:
    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.
     
  4. cPanelLauren

    cPanelLauren Forums Analyst II
    Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    3,042
    Likes Received:
    212
    Trophy Points:
    173
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    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!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice