Forum Discussion
iRule for redirect from URL to URI
I'm extremely new to iRules (2nd day) and am asking for help. I am having difficulty getting an iRule to take a url and redirect (or append) that same url with a "/abc"
Here is my current rule:
when HTTP_REQUEST { if {([string tolower [HTTP::host]] equals "http://host.123.com")}{ HTTP::header replace Host "http://host.123.com/abc" } }
Pretty straightforward, right? I thought so, but what happens is when I go to "http://host.123.com" and want it to send me to "http://host.123.com/abc," it does nothing and simply keeps me at "http://host.123.com"
Any direction here is greatly appreciated. Thank you for your time
2 Replies
- nitass
Employee
e.g.
config root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 3 } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo ltm pool foo { members { 200.200.200.101:80 { address 200.200.200.101 } } } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux ltm rule qux { when HTTP_REQUEST { if { [HTTP::host] eq "host.123.com" and [HTTP::uri] eq "/" } { HTTP::uri "/abc" } } } trace [root@ve11a:Active:In Sync] config ssldump -Aed -nni 0.0 port 80 New TCP connection 1: 172.28.24.1(35953) <-> 172.28.24.10(80) 1390404386.7216 (0.0020) C>S --------------------------------------------------------------- GET / HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Accept: */* Host: host.123.com --------------------------------------------------------------- New TCP connection 2: 200.200.200.14(35953) <-> 200.200.200.101(80) 1390404386.7286 (0.0045) C>S --------------------------------------------------------------- GET /abc HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Accept: */* Host: host.123.com --------------------------------------------------------------- - ngray_141868
Nimbostratus
Hi Nitass,
Thank you for the quick reply. I was able to make it work using another answer to another question you had posted.
Your answer, when HTTP_REQUEST { if { [HTTP::host] eq "host.123.com" and [HTTP::uri] eq "/" } { HTTP::uri "/abc" } } was very close to what I needed to achieve. To note what I am using (and it is working): when HTTP_REQUEST { if { [HTTP::uri] eq "/" } { HTTP::redirect "http://host.123.com/swbc" } }
Thanks againg for you help.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com