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 main domain but not subdomain?

Discussion in 'General Discussion' started by room9, Jul 17, 2011.

  1. room9

    room9 Member

    Joined:
    Jul 17, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    I have the main domain for my account redirecting successfully to another server. I have set up a subdomain and am pointing this subdomain to a directory on my hosting but this doesn't work - it looks like the subdomain is also being redirected (I am getting a 404 back from what looks like the remote hosting). I would like the main domain to redirect, but the subdomain to serve a directory like normal.
     
  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
    Can you post the contents of your /home/username/public_html/.htaccess file where username is the cPanel username for us to see how the redirect is being setup on your account?
     
  3. room9

    room9 Member

    Joined:
    Jul 17, 2011
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
    RewriteRule ^/?$ "http\:\/\/www\.another\.com\/subsite" [R=302,L]

    I know I can turn on redirection for www only but this means without the www I get nothing (public_html directory listing) as my subdomain site is in a separate directory.
     
  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 cannot reproduce this behavior with a subdomain after using that redirection content in my own main domain's .htaccess file. I basically used the following:

    Code:
    root@host [/home/tristan/public_html]# cat .htaccess
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^tristanwallace\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.tristanwallace\.com$
    RewriteRule ^/?$ "http\:\/\/google\.com" [R=302,L]
    This redirects tristanwallace.com to google.com but is not redirecting a subdomain http://happytime.tristanwallace.com/ to google.com

    I cannot see why this would be happening on your setup if you have a true subdomain setup on that account rather than parking the subdomain on the public_html of the account.
     
Loading...

Share This Page