Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Thu Apr 25, 2013 6:30 pm 
Offline
Newbie

Joined: Thu Apr 25, 2013 6:19 pm
Posts: 2
Hello!

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"

Code:
  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.


Top
   
PostPosted: Thu Apr 25, 2013 7:40 pm 
Offline
Senior Member

Joined: Mon Jan 02, 2012 12:45 pm
Posts: 365
I'm no mod_rewrite maven, but shouldn't your second condition exclude requests ending with ~dave?

I think you can the not operator:
Code:
RewriteCond %{HTTP_HOST} !^host-1-01\.example\.net\/~dave$


Top
   
PostPosted: Fri Apr 26, 2013 1:00 pm 
Offline
Newbie

Joined: Thu Apr 25, 2013 6:19 pm
Posts: 2
Turns out it required the REQUEST_URI variable, so:

Code:
        
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!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group