Forum Discussion
iRule redirect issue...
Hi there,
I've got a situation where I have a bunch a friendly urls that redirect to unfriendly urls. So, I created an iRule with a switch:
when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/path1" { HTTP::respond 301 Location "http://www.website.com/unfriendlypath1" } "/path2" { HTTP::respond 301 Location "http://www.website.com/unfriendlypath2" } "/path3" { HTTP::respond 301 Location "http://www.website.com/unfriendlypath3" } } } That's all good and all. Now, I need to add something so that if the user comes in on "http://website.com" (no www), I need to forward them to www.website.com first (i.e. so in their address bar, they see After that happens, if one of the friendly urls match, forward them there. If the uri doesn't match, then just forward them to www.website.com and add whatever uri they had originally. This would address someone coming in on http://website.com/ or http://website.com/otherpath/
Thanks for the help...
2 Replies
- Greg_Labelle
Nimbostratus
ProxyPass can help you with the specific url redirection without affecting the standard URI, see the link below for details.
https://devcentral.f5.com/codeshare/proxypass-v10-v11
- Stanislas_Piro2
Cumulonimbus
You can try this update:
when HTTP_REQUEST { if {[HTTP::host] equals "website.com"} {HTTP::respond 301 Location "http://www.website.com[HTTP::uri]"; return} switch [string tolower [HTTP::path]] { "/path1" { HTTP::respond 301 Location "/unfriendlypath1" } "/path2" { HTTP::respond 301 Location "/unfriendlypath2" } "/path3" { HTTP::respond 301 Location "/unfriendlypath3" } } }The first condition is to redirect website.com to www.website.com
I updated the HTTP respond with only relative URI and not absolute....
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