0

Context: I have little/no experience with Netscaler and I'm just starting to use them. One of the first jobs I've been given to work with it is what I thought would be a simple one. I have to have the URL http://www.example.com/subdomain/foo/bar redirected to http://subdomain.example.com/foo/bar. I'm hoping a Netscaler pro will just bat this one out of the park.

Here's what I have so far:

add rewrite action RW_TEST replace "HTTP.REQ.URL.QUERY.NAME_VALUE(\"www.example.com/subdomain\")" "\"subdomain.example.com\"" -comment "Test redirect"
add rewrite policy RW_POL_TEST "HTTP.REQ.URL.CONTAINS(\"www.example.com/subdomain\")" RW_TEST

The /foo/bar bit should remain untouched as part of the original request and eventual destination - I just want the subdomain bit rewriting. If the above looks good, please suggest that it does or suggest improvements. I hope it's clear.

My understanding is that this then needs binding to a vserver, which seems to be the easier bit!

pmelon
  • 21
  • 4
  • I have never used NetScaler, but the term `HTTP.REQ.URL.QUERY.NAME_VALUE` looked wrong right away. Looking at the documentation at http://docs.citrix.com/en-us/netscaler/10-5/ns-appexpert-con-10/ns-pi-gen-pol-config-wrapper-10-con/ns-pi-Adv-exp-eval-txt-wrapper-con/ns-pi-exp-prefix-txt-http-req-res-con.html confirmed my suspicion and it only matches the URL query arguments list, that is the string after `?` in URL. So this won't work. I think you need to use `HTTP.REQ.URL` in your `action` statement. – Tero Kilkanen Sep 30 '16 at 07:13
  • "I have little/no experience with Netscaler and I'm just starting to use them" what are you asking here then? This is not a tutorial website. – Massimo Jun 26 '21 at 00:26
  • I’m voting to close this question because "I have little/no experience with Netscaler and I'm just starting to use them"... what are you asking here then? This is not a tutorial website. – Massimo Jun 26 '21 at 00:27

1 Answers1

0

The question whether this is easy to accomplish or not, lies in the question how dynamic your redirects should be. In plain English: how many subdomains do you wish to support for this action?

If it is a limited set, you could use plains URL Transformation policies, which is a form of rewrite specifically available for these kinds of situations.

I can give you another, more dynamic way, but it would involve a lot of extra code. The dynamic way is based on CoreLogic, a framework a colleague of mine and I created for use on Citrix NetScaler. You can read more about it at https://netscalerrocks.com/netscaler/netscaler-core-logic-10-3-changes-enhancements/

Jan
  • 121
  • 3