Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a demo.domain.com and domain.com they both show the same information and point to the same folder.

How can I redirect all demo.domain.com visitors to domain.com?

share|improve this question
I see the htaccess tag, but you should specify your HTTPD so no one assumes. – Tim Jul 17 '12 at 20:03
There is a complete answer on stack overflow about this. Look [here][1]. [1]: stackoverflow.com/questions/2597474/… – MahmutBulut Jul 17 '12 at 20:16
up vote 4 down vote accepted

Assuming the HTTPD is apache:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^demo\.* [NC]
RewriteRule .* http://domain.com/ [L]
share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.