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!

Redirects and Hard Links

Discussion in 'General Discussion' started by coolcom, Mar 16, 2018.

  1. coolcom

    coolcom Member

    Joined:
    Mar 3, 2005
    Messages:
    21
    Likes Received:
    3
    Trophy Points:
    153
    I am missing something...

    I am trying to create a redirect so that if a user enters originaldomain.com/*, it will go to newdomain.com

    Should be easy... yes?

    I have no problem with getting both www.originaldomain.com and originaldomain.com to go to newdomain.com.

    However, if anything at all is typed after originaldomain.com, such as originaldomain.com/other folder... I get a not found error.

    I am NOT looking for wildcard... so no, I am not looking to send originaldomain.com/something to newdomain.com/something.

    I want originaldomain.com/something, originaldomain.com/otherstuff, originaldomain.com/folder/file.html and anything else to all go to the root of the forwarded domain, newdomain.com.

    This is not happening, and I had been taking for granted this was standard for a "hard link" forward.

    So... what am I missing?
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    Can you let us know the specific rewrite rules you are using in the .htaccess file within the document root of the original domain name? It's likely you will need to update the Mod_Rewrite rules for your specific criteria. StackOverflow is a useful resource for help with custom rewrite rules. Try entering the "Mod_Rewrite .htaccess redirect all files to new domain name site:stackoverflow.com" as a search term on Google and you should see several results with examples to test.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. coolcom

    coolcom Member

    Joined:
    Mar 3, 2005
    Messages:
    21
    Likes Received:
    3
    Trophy Points:
    153
    This is the current .htaccess file:


    RewriteEngine on

    #
    #RewriteEngine on

    #RewriteOptions inherit
    #RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
    #RewriteCond %{HTTP_HOST} ^www\.domain\-t\.com$
    #RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    #RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

    #RewriteRule ^/?$ "https\:\/\/newdomain\.co\/" [R=301,L]
    RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.com$
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^/?$ "https\:\/\/newdomain\.co\/index\.php\/en\/" [R=301,L]


    Yes, I was thinking something to do with Mod_Rewrite as well. I'll do as you suggest and research the above... we should be able to solve from there. Thanks,
     
    #3 coolcom, Mar 16, 2018
    Last edited: Mar 16, 2018
  4. coolcom

    coolcom Member

    Joined:
    Mar 3, 2005
    Messages:
    21
    Likes Received:
    3
    Trophy Points:
    153
    OK... so the .htaccess should look like:

    RewriteEngine on
    RewriteRule ^(.*)$ https: //newdomain.com/$1 [R=301]

    (space added to URL above to allow it to show)

    I changed it to that and all works as expected now.

    So yes, I probably need to make adjustments to the Mod_Rewrite. Will do so. Thanks.
     
    #4 coolcom, Mar 16, 2018
    Last edited: Mar 16, 2018
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