Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I own 2 domains sio-india.org and sio-india.com

What i want to do is redirect all the subdomains from 1st domain to 2nd domain. eg. home.sio-india.org to home.sio-india.com but i dont want to redirect sio-india.org to sio-india.com and also dont want to redirect www.sio-india.org to www.sio-india.com

Please help

I am using this code in htaccess but it is not working.

RewriteCond %{HTTP_HOST} ^(.*)sio-india\.org$ [NC]  
RewriteRule ^(.*)$ http://%1sio-india.com/$1 [R=301,L] 

Please hepl me I am stuck.

share|improve this question

migrated from stackoverflow.com Jun 15 '10 at 13:06

This question came from our site for professional and enthusiast programmers.

Are any redirects working? I.e. is the web server set up to respect rewrites defined in .htaccess? –  Lauri Lehtinen Jun 15 '10 at 4:08
So to summarize: redirect: //home.sio-india.org to //home.sio-india.com; Leave //sio-india.org alone; Leave //sio-india.com alone. Any other variations? What about www variations? And do all these sites live in the same webroot? –  artlung Jun 15 '10 at 4:23

1 Answer 1

It would be helpful to specify how exactly is it not working. It seems to me that your code would redirect everything (including http://sio-india.org). This is because .* means "any character, zero or more repetitions", so sio-india.org would match too.

You should change your condition to

RewriteCond %{HTTP_HOST} ^(.*)\.sio-india\.org$ [NC]  
RewriteRule ^(.*)$ http://%1.sio-india.com/$1 [R=301,L]

If that doesn't fix it - please be more specific about how it doesn't work.

share|improve this answer
Thanks it works perfecttly! I am using it on one of my sites. Was looking for a very long time. –  user172109 May 2 '13 at 9:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.