On URL redirect, is there a way to only get the query string?

This can be accomplished with content rules to inject the query string into the redirect path.

 

Create a 'Content Matching' rule and a 'Replace Header' rule.  

On the left hand side of the WUI, click Rules & Checking > Content Rules > Create New.

Header Field Location
Match String /(https?:\/\/)(.+\?)(.+)/
Value of Header Field to be replaced \1example.com?\3


mod_rule.png

Match String /.+/

match_rule.png

 

Create a SubVS and enable 'Content Switching'.

Assign the content matching rule (match_query), to the SubVS.

Within the parent Virtual Service, assign the keep_query rule under Advanced Properties > HTTP Header Modifications > Response Rules.

The final step is done within the SubVS in Advanced Properties > Not Available Redirection Handling. You can either set a 301 or a 302 with http://%h%s in the Redirect URL

It is important to note, that the SubVS must not contain any Real Servers. 

Also, this example outlines a port 80 unencrypted Virtual Service. The same concept applies for a port 443 service, however you must enable SSL Acceleration at the parent Virtual Service. The LoadMaster must be able to decrypt traffic.

In these examples, the following requests:

> GET /?kemp=loadmaster&support=true HTTP/1.1

> GET /query?kemp=loadmaster&support=true HTTP/1.1

> GET /query/test?kemp=loadmaster&support=true HTTP/1.1

> GET /query/test/balance.php?kemp=loadmaster&support=true HTTP/1.1

> Host: example.com

Will all return this 302:

< HTTP/1.1 302 Found 

< Location: http://example.com?kemp=loadmaster&support=true

 

Was this article helpful?

0 out of 0 found this helpful

Comments