Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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.