mod_rewrite: Problems with excluding ~dir
There are two things that I'm trying to do:
1) Redirect all requests for "host-1-01" to "vm-1-01"
2) Unless a user requests "/~dave" in "host-1-01.example.net/~dave"
RewriteEngine on
RewriteCond %{HTTP_HOST} ^host-1-01\.example\.net$
RewriteCond %{HTTP_HOST} ^host-1-01\.example\.net\/~dave$
RewriteRule ^(.*)$ http://vm-1-01.example.net [L,R]
Currently, step 1 only works if the second ~dave RewriteCond is commented out, and step 2 doesn't work unless step 1 is commented out (can't say it's really "working" though if it isn't redirected by default).
Much obliged for any help on this one.
2 Replies
I think you can the not operator:
RewriteCond %{HTTP_HOST} !^host-1-01\.example\.net\/~dave$
RewriteCond %{HTTP_HOST} ^host-1-01\.example\.net$
RewriteCond %{REQUEST_URI} ^host-1-01\.example\.net\/~dave
RewriteRule ^(.*)$ http://vm-1-01.example.net [L,R]
Cheers!