Server Fault is a question and answer site for system and network administrators. 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 WordPress site installed at and another testing WordPress site at I've successfully made redirect to with this .htaccess code:

RewriteCond %{HTTP_HOST} !^beta\.example\.com
RewriteRule ^(.*)$$1 [R=301,L]

However, when trying to go to it forces it to with a 404 error. Is there a way to have this beta redirect but still keep my WordPress site at working?

share|improve this question
up vote 0 down vote accepted

If I am understanding you correctly and you want to still go to You can add another condition and both conditions will have to be met for the rule to be followed. It would look like:

RewriteCond %{HTTP_HOST} !^beta\.example\.com
RewriteCond %{HTTP_HOST} !^test\.example\.com
RewriteRule ^(.*)$$1 [R=301,L]

Now neither beta nor test subdomains will redirect, but ALL others will.

If you only want or to go to the beta subdomain you could use

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule ^(.*)$$1 [R=301,L]

There is a nifty tool for checking mod rewrite rules at

Alternatively, if you have access to your servers zone file you could set up CNAME records for all domains that you want to point to the beta subdomain and no redirect would occur so that if a user goes to the URL remains the same when they are in fact on the beta site.

share|improve this answer
Adding another condition makes complete sense! Thanks for your help! – Brandon Jul 11 '13 at 4: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.