Newbie IRule Question on Redirects

I’m sorry but I’m relatively new to IRules and am having trouble getting an IRule to redirect to another site when traffic comes into a VIP.

I have this internal URL: http://test.corp.mycompany.com which resolves to the VIP address of 172.21.61.3 on port 80. Behind this VIP, I only have one test web server (172.21.69.3) that has a basic splash page. I created a new IRule called Test-redirect which is set to redirect to another internal web server…here is the rule:

when HTTP_REQUEST

{ if {[HTTP::uri] equals {test.corp.mycompany.com/1}}

{HTTP::uri {inside.corp.mycompany.com} } }

I applied this IRule to my VIP but when I go to http://test.corp.mycompany.com/1 , I don’t get redirected but get a 404 error instead.

Can anyone help me get this working?

thanks

jack

Hi jackster,

Try this:

when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/1" } {
HTTP::uri "/inside.corp.mycompany.com"
}
}

This will not change the URI in the browser. It will change the URI that is sent to the server.

The Browser will show: http://http://test.corp.mycompany.com/1

The Server will receive: http://test.corp.mycompany.com/inside.corp.mycompany.com

So you may want to analyze what you are wanting. You might want to change the the iRule to this:

when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] starts_with "/1" } {
HTTP::redirect "http://inside.corp.mycompany.com"
}
}

This will redirect you to a different website (http://inside.corp.mycompany.com).

Hope this helps.

That worked perfectly for me…thank you so much!

jack