Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 two subdomains, and, pointing to the same IP address. I want to redirect to I have this in my .htaccess file...

RewriteEngine on
RewriteCond {HTTP_HOST} b\.website\.com
RewriteRule ^(.*)$$1 [L]

...but it does not work.

Is there a way to make it work?

share|improve this question
up vote 9 down vote accepted

You could always use a simple VirtualHost:

<VirtualHost *:80>
  RedirectPermanent /

If you prefer to go with the .htaccess file, you're just missing a % sign on the Rewrite Condition:

RewriteEngine on
RewriteCond %{HTTP_HOST}
RewriteRule ^(.*)$$1 [L]
share|improve this answer
I tried both and they didn't work. I have mod_rewrite enabled and I have the VirtualHost in a separate site file. Is there anything that I'm missing? – Technius May 21 '13 at 5:16
This works fine. I had a loop redirect problem, because I was pointing a subdomain to a subfolder, and that subfolder was redirecting. Now, I redirect the subdomain to the URL that corresponds to the folder, and the 2nd redirection happens just fine! – Paschalis Jul 12 '14 at 9:29

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.