uri redirect

Folks, I am new to irules and not a very good scripter. Was very resistant to use them and now find that I am not going to get around it. So I am looking for some help. This seems like a simple kind of thing but I couldn’t find something similar enough to get it to work. I have a url

https://mydomain.com

for normal

mydomain.com/stuff/stuff/stuff I want it to forward as normal but I want it to say if the uri is /bla/bla/bla instead of /stuff/stuff/stuff redirect to a different url all together

So that is

https://mydomain.com/stuff/stuff - normal but for

https://mydomain.com/bla/bla/bla - redirect to

https://anotherguysdomain.com/bla/bla/bla

hope that makes sense.

Thanks for any help in advance!

Joe

This should be fairly straght forward assuming you are terminating SSL on the BIG-IP. If you are not decrypting the SSL, there is no way for the iRules to look at the content.

Here’s an iRule that should get you started.

when HTTP_REQUEST { 
   switch -glob [string tolower [HTTP::uri]] { 
     "/bla/bla/bla*" { 
       HTTP::redirect "https://anotherguysdomain.com[HTTP::uri]" 
     } 
   } 
 }

this will redirect all requests that start with /bla/bla/bla to the new domain and allow all others to the default pool. Just make sure this iRule isn’t running on the “anotherbuysdomain.com” virtual or you will get yourself into a recursive loop. If that’s a requirement, you can check the value of “[HTTP::host]” around the switch.

-Joe

Joe,

Thanks for the help. I am wondering is this going to put the /bla/bla/bla on the end of the otherguysdomain string? I just want to feed it a total different url if the /bla/bla/bla is on there.

This make sense?

Thanks

Joe

Your example was to convert

https://mydomain.com/bla/bla/bla → https://anotherguysdomain.com/bla/bla/bla

So, yes, this will take the existing URI passed in to mydomain.com and create the redirect to the new host with the existing URI. If you want to make the URI something different, change the HTTP::redirect line.

-Joe