Redirect to new URL, but keep certain part of the original URI path.
Hi All,
Can you guys help with this unique requirement? We need to match based on the URI the client comes in on (IAM), than redirect to a new URL while
changing IAM to IAM2, and keeping their unique URI hash...
Thanks for your help in advance!
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "test.abc.com" and [string tolower [HTTP::uri]] starts_with "/IAM/" } {
set temp_uri [HTTP::uri]
HTTP::respond 307 Location "https://new.abc.com/IAM2$temp_uri"
}
}
Requirements:
- match URI "/IAM" on the original URL
- Redirect the user to a new URL, however change the URI "IAM" to "IAM2" while taking the dynamic generated URI hash using the "set temp_uri"
and appending this to the new redirected to URL...
so basically anything after IDP should be carried over to the new URL as this is dynamically generated and can change. We need this...
"IDP/SSO.saml2?SAMLRequest=nZBNT4QwEIb%2FStN7WVo%2BCg2wqeAmJGqMr123ab%"
Example:
Original URL--> https://test.abc.com/IAM/IDP/SSO.saml2?SAMLRequest=nZBNT4QwEIb%2FStN7WVo%2BCg2wqeAmJGqMr123ab%
New Redirect to -> Should redirect to https://new.abc.com/IAM2/IDP/SSO.saml2?SAMLRequest=nZBNT4QwEIb%2FStN7WVo%2BCg2wqeAmJGqMr123ab%
The issue with the code above is that when we try this, the final redirect URL also appends the orginal "IAM" into the URL string. Is there a way to not do that and only add this and also keep anything after the "/IDP/SSO.saml2?......." as this is dynamic?
IAM2/IDP/SSO.saml2?SAMLRequest=nZBNT4QwEIb%2FStN7WVo%2BCg2wqeAmJGqMr123ab%
It adds the "IAM" as you can see below.....
https://new.abc.com/IAM2/IAM/IDP/SSO.saml2?SAMLRequest=nZBNT4QwEIb%2FStN7WVo%2BCg2wqeAmJGqMr123ab%