10-Sep-2015 11:29
I am struggling to get this to work. Here is the scenario:
https://mycompany.com/virtual.aspx?code=....&type=....
Redirect to:
https://egift.mycompany.com/egift.aspx?eid=.....&tid=.......
Any help would be appreciated
10-Sep-2015 11:54
The only values that are the same are the eid and tid. everything else is dynamic
10-Sep-2015 12:05
Let me try this again: Client enters https://mycompany.com/virtual.aspx we want to redirect to: https://egift.mycompany.com/virtual.aspx?code=.......&type=......
When I try to redirect based on URI the dynamic portion is cutoff. I need to pass the entire URI and dynamic content also
10-Sep-2015 12:10
How are you doing it now? If you're using HTTP::path to evaluate the URI, that will indeed ignore the query string portion of the URI.
10-Sep-2015 12:54
I was using HTTP path and the uri virtual.aspx to redirect
10-Sep-2015 13:01
Here is the I-Rule I initially came up with to redirect but it was chopping off the dynamic content
when HTTP_REQUEST { set uri [HTTP::uri] set host [HTTP::host] if { "$uri" contains "/egift" } { HTTP::redirect "https://egiftpp.mycompany.com/$uri" } }
10-Sep-2015
13:22
- last edited on
02-Jun-2023
16:15
by
JimmyPackets
can this be done this way
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "mycompany.com" } {
if {[HTTP::query] != ""}
{
HTTP::respond 302 Location "https://egiftpp.mycompany.com[HTTP::path]?[HTTP::query]"
}
else
{
HTTP::respond 302 Location "https://egiftpp.mycompany.com[HTTP::path]"
}
}
}
11-Sep-2015 01:00
Hi,
If I understand what you want in the first question:
after some added information, you only change hostname... can you explain each part that must be changed.
11-Sep-2015
06:15
- last edited on
02-Jun-2023
16:15
by
JimmyPackets
Will the value of eid and tid changes during redirection or remains same ?
for example.
Original Request
https://123.mycompany.com/egift.aspx?eid=abc123&tid=def123
Is this Redirection:
https://456.mycompany.com/egift.aspx?eid=abc123&tid=def123
or it has a different value
https://456.mycompany.com/egift.aspx?eid=pqr123&tid=xyz123
11-Sep-2015 06:41
Can I make a suggestion?
Assuming you're running a recent BigIP version, that is v11.4.0 and above, why not use a LTM Policy to do the job?
11-Sep-2015
08:27
- last edited on
02-Jun-2023
16:14
by
JimmyPackets
Thats what a LTM Policy would look like:
ltm policy mycompany.com_policy {
controls { forwarding }
requires { http }
rules {
egift {
actions {
0 {
http-reply
redirect
location https://456.mycompany.com[HTTP::uri]
}
}
conditions {
0 {
http-host
host
values { 123.mycompany.com }
}
1 {
http-uri
path
values { /egift.aspx }
}
}
ordinal 1
}
}
strategy first-match
}
11-Sep-2015 09:10
11-Sep-2015 10:45
11-Sep-2015 10:46
11-Sep-2015 11:01
12-Sep-2015 07:34
12-Sep-2015
01:19
- last edited on
02-Jun-2023
16:14
by
JimmyPackets
Hi,
You can use this irule to help you:
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] equals "mycompany.com") && ([HTTP::path] equals "/egift.aspx" ) } {
set eidval [URI::query [HTTP::uri] eid]
set tidval "b"
HTTP::respond 302 Location "https://egiftpp.mycompany.com[HTTP::path]?eid=$eidval&tid=$tidval"
}
}
As you can see, you can parse previous query to get parameters values and assign to parameters in redirect.
05-Oct-2015 14:39
I have tried to get the redirect to work without any success. Here is a better idea of what we are trying to redirect and the I-Rule I have used:
Here is what we are trying to do: 1.) https://www.mysite.com/egift.aspx?eid=&tid= - to be re-routed to https://egift.mysite.com/egift?eid=&tid=
Here is the I-Rule I used to attempt the redirect:
when HTTP_REQUEST { log local0. "Request [URI::query [HTTP::uri]eid]" if { ([string tolower [HTTP::host]] equals "mysite.com") && ([HTTP::path] equals "/egift.aspx" ) } { set eidval [URI::query [HTTP::uri] eid] set tidval [URI::query [HTTP::uri] tid] Log local0. "Request [HTTP::path]" HTTP::respond 302 Location "https://redirectsite.com[HTTP::path]?eid=$eidval&tid=$tidval" } }
When I turned on logging I recieved this response: Mon Sep 14 21:20:52 PDT 2015 info sc-preprod-DMZ-lb tmm1[29803] Rule /Common/egift-redirect2 : Request:eid=DM67JKKM4DBLXPYDS88KDX8PL0&tid=VMH5N8QQJA87XCF6022YZHG724&template=basiceid
The above I-Rule looks like it should work but it does not redirect correctly
06-Oct-2015
00:09
- last edited on
02-Jun-2023
16:06
by
JimmyPackets
Hi,
I tried the iRule and the I got the expected result:
$ curl -i "http://192.168.1.133/egift.aspx?eid=DM67JKKM4DBLXPYDS88KDX8PL0&tid=VMH5N8QQJA87XCF6022YZHG724&template=basiceid" -H "Host: mysite.com"
HTTP/1.0 302 Found
Location: https://redirectsite.com/egift.aspx?eid=DM67JKKM4DBLXPYDS88KDX8PL0&tid=VMH5N8QQJA87XCF6022YZHG724
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
06-Oct-2015 12:00
Thanks, I will run another test and verify.
08-Jun-2018 05:49
We are trying something similar and was trying to edit what you have but could not figure it out.
We are trying to rewrite using id number which will change and would like to append it redirect site below. in this case it is "12677"
https://localsite.com/publications/citation.aspx?type=FN&PubId=12677&PersonId=109
redirect to:
https://redirectsite.com/publicationid/12677
What do you think?
Thanks!!
08-Sep-2022 09:52
Hi I'm kind of surprised there's no simple answer for this.
We need to redirect (also see requirements below):
https://foo.bar.com/authorize/aaa/bbb/someFile.jsp?response_type=<some_dynamic_value>&client_id=<some_dynamic_value>&scope=<some_dynamic_value>&redirect_uri=<some_dynamic_value>
to
https://xxx.baz.com/authorize/aaa/bbb/someFile.jsp?response_type=<same_dynamic_value_from_request>&client_id=<same_dynamic_value_from_request>&scope=<same_dynamic_value_from_request>&redirect_uri=<same_dynamic_value_from_request>
Requirement #1: we can't use pools or policies.
Requirement #2: Only change requests coming into the path that starts with /authorize (e.g. https://foo.bar.com/authorize/etc. gets redirected). Other requests hitting the host with a different start to the path must remain unchanged (e.g. https://foo.bar.com/billling must stay the same).
Requirement #2: With a simple redirect, we want to change the host name only, and keep the paths in the redirect the same as in the request and keep all query params and their values in the redirect the same as in the request (values change dynamically with each request)