Need to redirect complete URL into redirected uri
Hello Everyone,
I am looking for an iRule for redirection of below https://URL1 into another https://2URL/redirect?url=https://URL1
Example:
Request: https://www.abc.com/find/redirect
Redirect: http://www.xyz.com/found/redirect?url=https://www.abc.com/find/redirect
Example: http://www.xyz.com/found/redirect?url=https%3A%2F%2Fabc.com%2Ffind%2Fredirect
Thanks in Advance:
ashk If your intent is to redirect anything going to www.abc.com with any URI path starting with "/find/redirect/" the following should work for you.
when CLIENT_ACCEPTED priority 500 { set DEFAULT_POOL [LB::server pool] } when HTTP_REQUEST priority 500 { set HOST [string tolower [HTTP::host]] set URI [string tolower [HTTP::uri]] if { ${HOST} == "www.abc.com" } { if { ${URI} starts_with "/find/redirect/" } { HTTP::respond 301 Location "https://www.xyz.com/found/redirect?url=https://$HOST$URI" } } else { $DEFAULT_POOL } }
Now if you want to redirect anything that connects to www.abc.com to www.xyz.com/found/redirect?url=https:// <old_path> the following should do the job.
when CLIENT_ACCEPTED priority 500 { set DEFAULT_POOL [LB::server pool] } when HTTP_REQUEST priority 500 { set HOST [string tolower [HTTP::host]] set URI [string tolower [HTTP::uri]] if { ${HOST} == "www.abc.com" } { HTTP::respond 301 Location "https://www.xyz.com/found/redirect?url=https://$HOST$URI" } else { $DEFAULT_POOL } }
If I am missunderstanding the request please provide a real world example of one of the requests or rewording the question so we can have a different approach to the issue at hand.