Jump to content
Welcome to our new Citrix community!

Netscaler: Redirect APEX to www

Kenneth Schall

Recommended Posts

The question is in regard to an MPX but should work the same with VPX - MPX wasn't an option in the forum post selection. 


Did a quick search and wasn't able to find what I really needed.  I've been asked to redirect our apex (domain.com) to the www (www.domain.com).  In DNS they both point to the same IP, so will use the same Virtual Server on the ADC.  I've done a few redirects, but not like this.  Can you search the URL for something that is "missing" (in this case, the "www") and then redirect it to the www.domain.com?  I know we can search to find certain things in the path but wasn't sure if we could find something that wasn't there (per se).

Link to comment
Share on other sites

So, with a HOST name redirect, you can do them BUT the name the users are using still has to get to the ADC for the ADC to do a redirect.  Can be done with a responder policy, but the action is a little different than the path redirects you are used to.


So, first lets say the web site is accessible whether you connect with the host names:





So, http(s)://domain.com/pathstuff/somepage.asp?somequery=values

or the other domains do in fact work.


So, the dns would still resolve the domain.com, demo.domain.com,  www.domain.com  to the VIP.

The DNS resolution ensures the FQDN resolves to the VIP and traffic arrives at the lb vserver (or other).


If a user just going to http(s)://domain.com/<pathstuff> will not actually connect to the ADC, then a responder policy won't be able to redirect this.


To redirect a HOST name to a new host name value:

Create a RESPONDER "REDIRECT" policy action.


With the redirect target, you can hardcode the hostname OR parse it, there will be a couple of examples below and you can parse the path/query onto the new hostname.

Example 1a: hardcode the specific HOST name you want to use. Also adjust for http:// vs. https://

"http://www.domain.com" + http.req.url.path_and_query


Example 1b: If you wanted to grab the original host name in use in the request and inser the "www." in front of. Use the policy expression to determine when to do this.

"http://www." + http.req.header("host") + http.req.url.path_and_query


Policy expressions to trigger the redirect:



With a few more details, the expression could be modified to better fit your scenario.


  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...