uri manipulation
4 TopicsAdvice to partial rename uri path
Hi there masters! I would like to ask for advice. Is there a possibility that after I redirect an URL I can partial rename the 1st two paths in the redirected URI path? So, for example: when client requested our main page... "https://companyA.com/" I will redirect this to a path of "https://companyA.com/room/desktop/r/Home".. Then, I will hide/or rename the 1st two paths and this will appear on client's browser as "https://companyA.com/bed/table/r/Home". /bed/table uri path are strings not location or directory. Would this be plausible? I really just want to change their strings. I tried to code it but only the redirect is successful except for the changing of the names of the two paths: When HTTP_REQUEST{ if {([HTTP::host] equals "companyA.com" and [HTTP::uri]equals "/")}{ HTTP::redirect "https://[HTTP::host]/room/desktop/r/Home" } } When HTTP_RESPONSE { if {[HTTP::header exists "Location"]}{ HTTP::header replace "Location" [string map {"/bed/table" "/room/desktop"} [HTTP::header "Location"]] } } Can you help me on this? Thanks! Regards, ZeigSolved102Views0likes8CommentsDynamic Redirect iRule URI Variable
I am trying to perform a dynamic redirect based a portion of the URI. Here is what I'm trying to accomplish: Ex. Request: http://search.company.com/Pages/results.aspx/k=accounting%20department Ex. Redirect: https://www.company.com/search/?&query=accounting%20department We are using a separate virtual server for search.company.com, so I created the following iRule and associated it with the virtual server: when HTTP_REQUEST { set uri [HTTP::uri] if { $uri starts_with "/Pages/results.aspx/k=" } { log local0. "Original URI: $uri" HTTP::uri [string range [HTTP::uri] 23 end] log local0. "Search Query: [HTTP::uri]" HTTP::uri /search/?&query=[HTTP::uri] log local0. "New URI: [HTTP::uri]" HTTP::redirect "https://www.company.com[HTTP::uri]" } elseif { $uri starts_with "/Pages/results.aspx" } { HTTP::redirect "https://www.company.com/search" } } Unfortunately, this is not having the desired result. Here is the behavior I am seeing: Request: http://search.company.com/Pages/results.aspx/k=accounting%20department Redirect: https://www.company.com/search/?&query=k=accounting%20department I attempted to find the log entries for this iRule, but was unable to. Can anyone offer any guidance of how I can accomplish this? Or at the very least, where I need to look for log entries and what log level needs to be enabled for which types? Also, please feel free to correct anything you find in the iRule, whether or not it is directly contributing to the issue. I'm still learning, and trying to figure out the best way to accomplish things, as well as general best practices. Thank you for your time and input.491Views0likes2CommentsLocal Traffic Policy for complex URI transform; order of eval relative to iRules
New to 11.4, and getting my hands around Local Traffic Policies. I have a scenario in which I evaluate starts-with against the URI, and depending on value, select a pool. But for certain URIs, I also change the URI in a non-trivial manner. For example: when HTTP_REQUEST { if {[HTTP::uri] starts_with "/MP"} { pool pool1 } elseif {[HTTP::uri] starts_with "/MA/2.00"} { HTTP::uri [string map {"/MA/2.00" "/MA"} [HTTP::uri]] pool pool2 } } First – how do I do that URI transformation with a Policy? Target: http-uri has parameters of path, query-string and value. Can I just select “value” and add “[string map {"/MA/2.00" "/MA"} [HTTP::uri]]”? I mean, does an action get evaluated that way, such that you can use TCL string functions and data class references? As an alternative, I considered using the Policy to select a pool (easy to do), and leaving the URI transform as a smaller, simpler iRule – but which gets run first, the Policy or the iRules? If the iRule went first, it would prevent to Policy "URI starts-with" condition from being met, because the URI would have been changed to not match, and no pool would get selected. Sorry if this kind of thing is clarified somewhere – I couldn’t find it if so.273Views0likes3CommentsNeed to delete extra "/" in the URI
Hi Guys, Our developers found an issue where the page is getting 404 error when there is an additional "/" at the end of the page. So I am thinking of an irule which would remove the additional "/" at the end of the uri, following is what I am tried and getting a TLS error, can you please suggest me how can I get this working. when HTTP_REQUEST { if { [HTTP::uri] ends_with "/" } { HTTP::uri [[HTTP::uri] string map {"/" ""}] } } Following is the error that I received Aug 18 23:26:38 tmm err tmm[8726]: 01220001:3: TCL error: /Common/log-uri - invalid command name "/" while executing "[HTTP::uri] string map {"/ " " "} " Please let me know what is the cause for the failure. Thanks -Rajesh175Views0likes2Comments