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 with every thing after the domain name

Discussion in 'General Discussion' started by fcbinfo, Jan 10, 2014.

  1. fcbinfo

    fcbinfo Well-Known Member

    Joined:
    Dec 10, 2006
    Messages:
    120
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Tried to look for some tutorials of cPanel and Apache, but every thing that I found didn't solve my problem.
    If you add parked domain and redirect this domain, it works, but not if you have something after the domain name.

    Code:
    http://www.domain.net to http://www.domain.com
    This works...but

    If you input something after the domain not work
    Code:
    http://www.domain.net/somenthinghere to http://www.domain.com/somethinghere
    It still with .net and don't change to .com

    Can someone help-me with this.
    Thank you!
     
    #1 fcbinfo, Jan 10, 2014
    Last edited: Jan 10, 2014
  2. fcbinfo

    fcbinfo Well-Known Member

    Joined:
    Dec 10, 2006
    Messages:
    120
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Have found the solution, with default redirect of cPanel don't work, but with this configuration now I have it working. Look.

    Original from cpanel redirect: (Not working)
    Code:
     
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.net$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.net$
    RewriteRule ^/?$ "http\:\/\/www\.domain\.com\/$1" [R=301,L]
    

    Working code, with redirect all the links after the domain
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.net$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.domain\.net$
    RewriteRule (.*)$ "http\:\/\/www\.domain\.com\/$1" [R=301,L]
    
    Difference only on the ^/?$ to (.*)$
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

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

Share This Page