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'm dying on this htaccess:

RewriteCond %{HTTP_HOST} ^[www\.]?old\.com [NC]  
RewriteCond %{REQUEST_URI} ^.+$  
RewriteCond %{REQUEST_URI} !^wp-admin  
RewriteCond %{REQUEST_URI} !^index  
RewriteCond %{REQUEST_URI} !^subdomain  
RewriteRule ^(.*)${REQUEST_URI} [R=301,L]  

I'm trying to redirect all traffic from to EXCEPT when they access:

I still want the old site to show up and be able to administer it, but any should be redirected to

That's the other thing, I couldn't get this to work by using $1 as a backreference. I had to hard-code the %{REQUEST_URI} in there instead (which worked).

The last exmaple ( is a second website entirely and I don't want to interfere with its operation either.

I've read so, so many websites and every variation makes perfect sense from a regular expression point of view and they all should work, but they don't. This is driving me crazy.

share|improve this question

migrated from Apr 10 '11 at 20:23

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

Try these rules in your .htaccess:

RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]  
RewriteCond %{REQUEST_URI} !^/?(wp-admin|index|subdomain) [NC]
RewriteRule ^(.+)$$1 [R=301,L,QSA,NE]

Let me know if it doesn't work.

share|improve this answer
No change of any kind. Also I want to be able to visit and see the parked page I put there while only redirecting to the new when they try to access – user77914 Apr 10 '11 at 22:46
@user77914: I made a minor correction, please try again. Also if you notice I am only redirecting .+ which means will NOT be redirected to – anubhava Apr 10 '11 at 23:48
It still redirects all requests for to I'm starting to think there's some other issue at hand here, but I've commented out nearly every other line in the file except for RewriteEngine on, RewriteBase /, Options +FollowSymLinks, and the few lines Wordpress adds for pretty permalinks. – user77914 Apr 11 '11 at 1:16
Just for testing comment both the RewriteCond lines and have your RewriteRule like this RewriteRule ^(wp-admin)$$1 [R=301,L,QSA,NE] . That should start redirecting ONLY wp-admin but leave everything else as is. – anubhava Apr 11 '11 at 11:56

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.