Forum Discussion
Advice to partial rename uri path
- Jul 23, 2024
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" } } } }
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" }
}
}
}
- fred_zeig77Jul 23, 2024Altostratus
Alrighty! Thank you master! Will try this irule now.... Thanks again! :)
- fred_zeig77Jul 24, 2024Altostratus
Thanks sir! It works it was masked now. But, I could see some images of ours got broken. Perhaps this was because of how it was coded. We only did use basic html for testing? We have not use this irule on production yet.
But, yes it did mask now. Thanks a Lot!!
- CA_ValliJul 24, 2024MVP
Try using developer tools to understand how that image is called .. my suspicion would be that it referenecs the root folder "/"
- fred_zeig77Jul 25, 2024Altostratus
Ok thank you so much master! understood!
- fred_zeig77Jul 29, 2024Altostratus
Hi master!
Greetings! again. Is it okay to ask again for confirmation if you are still available? I notice in the code that because the path of our homepage has changed and masked the path on the side of client's browsers. What if our clients press a button containing a link to another path? would that give us an error 404 since the path the browser knows is the "/bed/table/...../"?
So, if lets say they click a login page button with a link at supposed uri path "/room/desktop/r/Home/Login" from "/room/desktop/r/Home" and this was masked to "/bed/table/r/Home"... Will client's browser able to direct to "/room/desktop/r/Home/Login" with the mask uri path or will this give them an error 404 code since the browser will shoot an HTTP get request header of path "/bed/table/r/Home/Login" when clients click the page's login link/button?
Apologies for the too many questions. This is my 1st time programming and use TCL/irule language. :)
Respectfully,
Zeig
- CA_ValliAug 30, 2024MVP
Hello, sorry for taking this long to respond, I was on hohliday.
So, the purpose of the iRule is to redirect clients to a "fake path" while still preserving the "real path" in server-side communication.
I've written it to be an exact match, as the only way to change the path in client broswer is performing an HTTP redirect; I don't expect clients to know that "/bed/table" does NOT exist.
If there's hyperlinks that point to /room/desktop/r/Home/Login , client browser will use the information in the hyperlink to perform a brand new GET request using the path that's provided -- this means that clients will be able to reach the "real path" on the server-side directly, and browser will display the real url in this case. iRule will NOT intercept them as the intruction is an exact match.
If you require dynamic matching we need to change the switch statements and add some extra code to preserve the rest of the uri
- CA_ValliAug 30, 2024MVP
This should be an upgrade
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" } "/room/desktop/*" { #this code portion will force client redirects, enforcing browser to display "bed table" fake url set maskedURL "/bed/table/[substr [HTTP::uri] 14 0]" #replacing the first 14 characters off your URL. set to match exact length of "/room/desktop/" HTTP::redirect "https://[HTTP::host]/$maskedURL" } "/bed/table/*" { #this code portion rebuilds the correct server url set rebuiltURL "/room/desktop/[substr [HTTP::uri] 11 0]" #replacing the first 11 characters off your URL. set to match exact length of "/bed/table/" HTTP::uri "$rebuiltURL" } } } }
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