Forum Discussion
Dennis_Jalbert
Nimbostratus
Sep 24, 2011Complex Redirect
I’m trying to create a redirect which changes the FQDN, keeps part of the URL static, and preserves the remaining part of the URI. That static part is going to be different on each side of the redirect though. Here is an example:
hosta.site.com/blah1/blah2/blah3/*
should redirect to
hostb.site.com/something1/something2/something3/*
where * could be anything that needs to be copied over.
It seems like I need to assign the wildcard part to a variable and then just use that in the redirect statement, but I’m not sure how to do that. I haven't done anything this complex before and I wasn't able to find anything like this by searching for forums. Thanks in advance!
4 Replies
- The_Bhattman
Nimbostratus
Hi Dennis,
It's a bid hard to suggest without diving into your example. However the first step I think is outline some commands that might be helpful
For example URI:: command would help you parse the path or query or port
http://devcentral.f5.com/wiki/iRules.URI.ashx
I hope this is a good start
Bhattman - Patrick_Chang_7Historic F5 AccountThe split command will allow you to separate the URI into sections (based upon the separator - "/" seems the most logical one to use here).
- Hamish
Cirrocumulus
Coming from a perl perspective, I'd probably use a regex myself... But timings may force another approach. Long uri strings with many /'s in them may make using split unweildy.
Testing would show the best approach from a myriad of possibilities.
H - Dennis_Jalbert
Nimbostratus
Hey guys,
Thanks for the help! I was able to do what I needed by using the HTTP::path and the string map command to change the static part of the URI. Then I used the HTTP::redirect command to change the hostname.
Sorry for not posting sooner, but the forums don't work when I'm on the company network and I kept forgetting to update this when I get home.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects