.htaccess subdomain redirect problem
Posted
by
Ali
on Stack Overflow
See other posts from Stack Overflow
or by Ali
Published on 2010-12-25T14:36:20Z
Indexed on
2010/12/25
14:54 UTC
Read the original article
Hit count: 239
Hi,
I have a website let's say www.example.com
and I have a subdomain something.example.com
Both main domain and sub domain are pointing to directory "public_html"
I have .htaccess on root which redirects any URL without www to www.
For e.g. if user enters example.com then he will be redirected to www.example.com
If user enters example.com/mypage.html
then he will be redirected to www.example.com/mypage.html
Now the problem is this is also affecting my subdomain. Because if someone enters something.example.com/visit.html
then he is redirect to www.example.com/visit.html
I don't want this! If user enters subdomain then I don't want to redirected to www domain. This is what I have in my .htacces file
RewriteCond %{HTTP_HOST} !^www.stackoverflow.com$ [NC]
RewriteRule ^(.*)$ http://www.stackoverflow.com/$1 [R=301,L]
Can you please tell me what should I do to solve above problem?
Thanks.
© Stack Overflow or respective owner