Forum Discussion
removing part of uri in redirect
We are moving servers and our paths from site to application are changing. For example, I have a current path of testsite.com/applications/testapp/lowerfolder/lowerfolder/test.aspx?param1=1¶m2=2
I need to have it redirect to testsite.com/testapp/lowerfolder/lowerfolder/test.aspx?param1=1¶m2=2
The parameters and the pages could change along with the two lowerfolders. All I need to do is remove the /applications from the path. Could anyone help with this?
I have BIG-IP version 11.1
Thanks,
Deni
16 Replies
- djkromarek
Nimbostratus
Using Kevin's rule, I put in the logging and it looked like everything that was under the host testsite.com and within the applications part (not just testapp) went through this rule and logged that it tried to send it to testsite.com/applications/testapp/.... This was every application within the /applications folder not just /testapp. I've had to remove the rule since it seems to want to route everything to the same page. I do not want every application within /applications to go to the redirect, only the application called /testapp. Is there some explanation as to why every application tries to follow the redirect? - Kevin_Stewart
Employee
I do not want every application within /applications to go to the redirect, only the application called /testapp
I don't think I got that from your original request. Try this:when HTTP_REQUEST { log local0. "incoming URI: [HTTP::uri]" if { [HTTP::host] contains "testsite.com" } { if { [string tolower [HTTP::uri]] starts_with "/applications/testapp/" } { set newpath [HTTP::host][string map {"/applications/testapp/" "/testapp/"} [HTTP::uri]] log local0. "redirecting to https://$newpath" HTTP::redirect "https://$newpath" } } } - djkromarek
Nimbostratus
At this time, we do not have a test F5, so I am having to apply this on a production F5. I wont be able to apply this rule to test until after work hours. I'll let you know the results in here. - djkromarek
Nimbostratus
It is still redirecting to /applications/testapp. Although now it seems to be only redirecting the testapp, but still going to the /applications folder. It gives an error that The page isn't redirecting properly it still gives the message that ' Firefox has detected that the server is redirecting the request for this address in a way that will never complete.' I need to check out the other iRules that may be affecting this application. But it doesn't seem to be dropping the /applications part of the URI. - Kevin_Stewart
Employee
What do the log statements say? - djkromarek
Nimbostratus
Below is the iRule that worked. when HTTP_REQUEST { if { [HTTP::host] contains "testsite.com" } { if {[string tolower [HTTP::uri]] starts_with "/applications/testapp/" } { set URI [substr [HTTP::uri] 14] HTTP::redirect "http://[HTTP::host]/$URI" } } }
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