The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

redirect to without www. error

Discussion in 'General Discussion' started by spiderlinginc, Oct 16, 2010.

  1. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I am trying to redirect my alias domains to my primary domain without the www. in the "redirect to" field, and I'm getting the error below. However, if I remove the trailing slash and change nothing else the redirect is applied, but doesn't work when browsing, which I understand.

    cPanel 11

    So, for example:

    ## does not get applied
    http://(www.)?aliasdomain1.ca/ redirects to→ http://primarydomain.com/
    "Redirect with or without www." is selected and "Wild Card Redirect" is checked

    ## does get applied
    http://(www.)?aliasdomain1.ca/ redirects to→ http://primarydomain.com
    "Redirect with or without www." is selected and "Wild Card Redirect" is checked

    ## error
    Redirecting to http://primarydomain.com/ will cause a redirection loop because 'http://aliasdomain1.ca/'

    which is located at /home/uname/public_html/

    is above 'http://primarydomain.com/'

    which is located at /home/uname/public_html/
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    To clarify, your alias domains are parked domains that already exist on the account and you are trying to redirect the parked domains to the non-www version of your primary domain?
     
  3. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Yes to both.
     
  4. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    I used the following for a parked domain of mine and it worked for the redirection:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^parkedomain.com$
    RewriteRule ^(.*)$ http://maindomain.com/$1 [R=301]

    This was placed into the .htaccess file in public_html on the account.
     
  5. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Thanks Danielle. That worked! I've tweaked it slightly and included it below for others.

    My question though, why does it not work when I try to do the same thing via the cPanel Redirects?

    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^www.primarydomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^(www.)?aliasdomain1.ca$ [OR]
    RewriteCond %{HTTP_HOST} ^(www.)?aliasdomain2.com$
    RewriteRule ^(.*)$ http://primarydomain.com/$1 [R=301]
     
  6. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Most likely because the redirection area in cPanel cannot take such complex arguments as using these regex statements. It's just a simple 301 redirection in that area of cPanel.
     
  7. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    The only difference between the redirect without the www. being accepted or not being accepted was whether or not I had the trailing forward slash. Complexity?
     
  8. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I just tried browsing to the site using https and it is not working. It is redirecting in a way which will never complete.
     
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The redirection provided is not specifically setup for https and that wasn't originally noted in your post as being needed. Can you clarify how the https is going to redirect? Is it https://parkedomain.com to https://maindomain.com ?
     
  10. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Sorry. I thought it was only going to affect http requests.

    https://primarydomain.com
     
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
  12. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    If it is https://(www.)?parkeddomain.com or https://www.primarydomain.com then redirect to https://primarydomain.com.

    Basically, same as the http protocol conditions that you helped me with.
     
  13. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Try the following:

    RewriteEngine on
    RewriteCond %{SERVER_PORT} 443
    RewriteCond %{HTTP_HOST} ^www.primarydomain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^(www.)?aliasdomain1.ca$ [OR]
    RewriteCond %{HTTP_HOST} ^(www.)?aliasdomain2.com$
    RewriteRule ^(.*)$ https://primarydomain.com/$1 [R=301]

    I cannot guarantee this will work as I don't have https on the account I used for testing to try it out for those domains.
     
  14. spiderlinginc

    spiderlinginc Member

    Joined:
    Mar 15, 2010
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    For the most part it is working. I had to add RewriteCond %{SERVER_PORT} 80 to the beginning of previous rewrite code I am using for the http redirect.

    The other thing is, if one of the parked domains is used with https I then get the warning for the domain in the address bar not matching the domain the certificate is assigned to. It seems that the htaccess file isn't read beforehand.
     
  15. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The .htaccess isn't and cannot be read before it tries to pass the certificate on the parked domain. There is no way to overcome that actually. I've tried to find a way before and it's not possible given how the data comes through from what I've researched. Any https to https redirect will cause the first domain to try to load the initial cert first before the redirect.
     
Loading...

Share This Page