Author Topic: Redirect with conditional "?" + query params  (Read 803 times)

Offline ohlol

  • Contributor
  • *
  • Posts: 1
  • Karma: 1
Redirect with conditional "?" + query params
« on: June 02, 2009, 10:07:47 PM »
First, thanks for the site. Most of my experience is with localDirectors and haproxy so I've made great use of the info here.

I've got a responder on my Netscaler:

add responder action redirect_to_www respondwith "\"HTTP/1.1 301 Moved Permanently\r\n\" + \"Location: http://www.domain.com\" + HTTP.REQ.URL.PATH + \"?\" + HTTP.REQ.URL.QUERY + \"\r\n\"" -bypassSafetyCheck YES

This works great, except if a request hits the policy that uses this responder without any query params, it still gets a "?" at the end of the URL, and gets redirected to: "http://www.domain.com/?"

Is there any way to add the `\"?\" + HTTP.REQ.URL.QUERY' only if HTTP.REQ.URL.QUERY is not empty?

I admit this is pretty much just a cosmetic thing, but it bugs me. :P

Offline evildani

  • Administrator
  • Hero Member
  • *****
  • Posts: 389
  • Karma: 22
Re: Redirect with conditional "?" + query params
« Reply #1 on: June 04, 2009, 07:58:54 AM »
there is a policy that is req.http.url.path_and_query try that, the ? should be added automatically.

Daniel