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 SSL Domain A to SSL Domain B

Discussion in 'Security' started by Avalon, Nov 30, 2015.

  1. Avalon

    Avalon Member

    Joined:
    Apr 27, 2015
    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    United States
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    I feel like this shouldn't be so difficult to do as the task takes all of two seconds in IIS but we are sitting here trying to redirect an SSL domain to another page on another SSL domain. For example:

    https://exampleA.com redirects to https://exampleB.com/exampleA.

    This is a trivial task under IIS and in terms of Linux, I have personally tried every conceivable way I know of to force a said redirect but always reach the "/" forbidden page although cPanel's built in redirection works for non-SSL redirection to the second SSL site.

    I have searched up and down Google to no avail so I figured I pose the question: how can I do this so that both non-SSL and SSL redirect to another SSL domain similar to my example above?
     
  2. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    942
    Likes Received:
    56
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    Are you dealing with parked/addon domians or does exampleA.com have its own document root (i.e. it's own public_html dir)

    edit; this may or may not help you due to ssl differences and such, but to carry over the domain name this works:

    Code:
    RewriteEngine On
    RewriteCond %{http_host} ^domainA.com [NC]
    RewriteRule ^(.*)$ http://www.domainB.com/%{http_host} [R=301,L]
    
    This ends up functioning as if you visit domaina.com you end up at domainB.com/domainA.com
     
    #2 quizknows, Nov 30, 2015
    Last edited: Nov 30, 2015
    Avalon likes this.
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    667
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Could you let us know the specific error message in /usr/local/apache/logs/error_log when you reach the forbidden message in your browser?

    Thank you.
     
  4. Avalon

    Avalon Member

    Joined:
    Apr 27, 2015
    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    United States
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Unfortunately, this is one of the first things I tried but I tried it again to just make sure. No joy unfortunately: the server lands on the forbidden page with SSL.

    To answer your question: yes, each domain has its own document root and thus a separate account for easier manageability and enterprise mobility. In the end though, we are still talking about redirecting 25 domains to a 26th domain as well as a very specific page within the 26th domain.

    I can't believe how stubborn its being on the CloudLinux box. On Win 2K12 R2 DC, getting such a redirect setup took all of maybe 5-6 clicks.

    Each of the 25 domains have valid certificates as does the 26th.

    Most certainly.This was the last log entry made by Apache at around the time the domain was accessed for redirection (SSL to SSL):

    Code:
    [Wed Dec 02 03:59:26.395551 2015] [lsapi:notice] [pid 829769:tid 139637097989888] [client SERVER IP AND PORT REMOVED] [host domainB.com] apr_table__get(REDIRECT_STATUS) ret ((null))
    Edited to make correction to Apache log: shows the destination domain ("domainB.com") and not the origin domain ("domainA.com"). Server IP is also displayed as the IP to the destination domain which has its own dedicated uplink as well as a really high number port (50000's)
     
    #4 Avalon, Dec 2, 2015
    Last edited: Dec 2, 2015
  5. quizknows

    quizknows Well-Known Member

    Joined:
    Oct 20, 2009
    Messages:
    942
    Likes Received:
    56
    Trophy Points:
    28
    cPanel Access Level:
    DataCenter Provider
    You could always put an index.php in each document root with this code, so it wouldn't care if the initial visit was http or https:

    Code:
    <?php
    header('Location: https://targetdomain.com/originaldomain');
    ?>
    
     
    Avalon likes this.
  6. Avalon

    Avalon Member

    Joined:
    Apr 27, 2015
    Messages:
    19
    Likes Received:
    1
    Trophy Points:
    3
    Location:
    United States
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Okay, strike everything I said. It seems that this problem stemmed from the fact that our Network Authority never issued the certificate for the domain until today so CloudFlare Enterprise didn't recognize it as a valid SSL certificate under strict settings. Now that the certificate has been issued, it does, and rather than reaching the forbidden page it redirects to the proper target domain.

    I guess when you are working with so many domains and servers sometimes the small things are just assumed and thus overlooked.
     
    #6 Avalon, Dec 3, 2015
    Last edited: Dec 3, 2015
    quizknows likes this.
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    667
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page