Redirect main domain but not subdomain?

room9

Member
Jul 17, 2011
5
0
51
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.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
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?
 

room9

Member
Jul 17, 2011
5
0
51
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.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
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:
[email protected] [/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.