Forum Discussion
Redirect URL
Hi,
I am looking to redirect http://www.examplesite.com/Examplepage.html to an external site like http://www.externalsite.com/
As I understand it there are multiple ways to do this so I have 2 questions about it.
- Which is the best way to do this?
- Which is the easiest way to do this?
I have tried multiple methods in doing this and have failed each time. Namely:
- https://devcentral.f5.com/questions/simple-url-redirect-irule
- https://devcentral.f5.com/questions/irule-for-http-redirect-from-retired-url-to-new-url
- Redirect Policies
- Rewrite Service
Thanks in advanced.
I had a similar situation. What i did was: * create a pool with no active members * create a VS and assign this pool to it * create an irule which looked at the of active members in the pool and if is 0 then redirect to external URL The irule is as below:
when HTTP_REQUEST { if { [active_members TS-EmptyPool] == 0 }{ HTTP::redirect "https://www.surveymonkey.com/s/eg.survey" } }
karthik
- IheartF5_45022Nacreous
Assuming the virtual only hosts a single domain
when HTTP_REQUEST { if {[string tolower [HTTP::path]] eq "/examplepage.html"} { HTTP::respond 301 noserver Location "http://www.externalsite.com/" return } }
Otherwise if www.examplesite.com is a vhost on the virtual try this;-
when HTTP_REQUEST { if {[string tolower [HTTP::path]] eq "/examplepage.html" && [getfield [HTTP::host] : 1] eq "www.examplesite.com"} { HTTP::respond 301 noserver Location "http://www.externalsite.com/" return } }
Now as to what's best/easiest....it's a matter of personal taste really. For me an iRule is easiest, however in theory a Local Traffic Policy or Rewrite Service is more efficient. Try them all and see what suits you....
Let me know if the iRule doesn't work for you.....
- Hi, Either doesn't work for me. The same page just loads.
- johtte_168100Nimbostratus
if you want to redirect to two diffent pools based on path? How the irule change?
Thanks for your help
- Karthik_Krishn1Cirrostratus
I had a similar situation. What i did was: * create a pool with no active members * create a VS and assign this pool to it * create an irule which looked at the of active members in the pool and if is 0 then redirect to external URL The irule is as below:
when HTTP_REQUEST { if { [active_members TS-EmptyPool] == 0 }{ HTTP::redirect "https://www.surveymonkey.com/s/eg.survey" } }
karthik
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