Advice 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,
Zeig
That's some very specific stuff you're trying to achieve ..
If the "client URL" you want to display does not exist on the server, I think you'll need two instructions in the iRule, one to redirect client to target URI and one to change this string before it connects to the webserver.
You might try something similar to this
when HTTP_REQUEST { if { [HTTP::host] equals "companyA.com" }{ #I'm using a switch statement so it's easier to add/change uri behavior in the future switch -glob [HTTP::path] { "/" { HTTP::redirect "https://[HTTP::host]/bed/table/r/Home" } "/bed/table/r/Home" { HTTP::path "/room/desktop/r/Home" } } } }