Forum Discussion
Specific URL redirection and other redirection should be unavailable
Hello Guys, Your urgent suggestion required on below case which I got recently to implement in production and as long as I know it could be done through i-rules but its’ TCL script and in which I don’t have much idea so it will be very glad to see some solution on this from your side
Requirement:- If anyone call an external URL www.abcd.com that should be redirect to specific path like/def/geh/100 (full path then backend server (I have done this) but if any one call same external URL with manual trail path like / desd/pqr/100/bsd etc then no redirection at all and there should be some message page that “webpage not available etc “ In short only the following URL should be redirect - /def/geh/100 and rest all redirection should be blocked or unavailable.
Thanks, Sonu kumar
4 Replies
- IainThomson85_1
Cumulonimbus
I'll give this is a go
when HTTP_Request { if { HTTP::URI equals "/def/geh/100" } { pool ithinkyouwantapool } else { HTTP::redirect "http://soundslikeyoushouldntbehere.com" } }
- sonu_kumar4
Altostratus
Hi Lain, Thanks for reply :) As I checked you have mentioned that when HTTP_Request { if { HTTP::URI equals "/def/geh/100" } mean (as long as I understand) if in the http request URI equal to this path then move to this backedn server rest all set to the given URL right but in my case user is just typing the simple url www.abcd.com in his/her browser that's it and further redirection /def/geh/100 should be done on F5 then backend server also any other URL should not be allowed with same URL. Please correct me if I'm wrong. - IainThomson85_1
Cumulonimbus
Odaah has posted an iRule below that iincludes the host element. :)
- Vijay_E
Cirrus
Try the following with iFile:
when HTTP_REQUEST { if { ([HTTP::host] eq "www.abcd.com") and ([HTTP::uri] eq "/")} { HTTP::uri [HTTP::uri]/def/geh/100 pool POOL_WEB_SERVERS } else { HTTP::respond 200 content [ifile get "maint_index_html"] Cache-Control No-Cache Pragma No-Cache } }A simpler version:
when HTTP_REQUEST { if { ([HTTP::host] eq "www.abcd.com") and ([HTTP::uri] eq "/")} { HTTP::uri [HTTP::uri]/def/geh/100 pool POOL_WEB_SERVERS log local0. "New URI - [HTTP::uri] - [LB::server pool]" } else { HTTP::respond 301 Location "http://redirectpage.com" Cache-Control No-Cache Pragma No-Cache } }
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