Jump to content
Welcome to our new Citrix community!

301 to redirect from one URL to another


Prit Singh

Recommended Posts

Good morning,

 

You can use the Rewrite or Responder feature of the NetScaler to achieve this.  Please take a look at the following blog post by George Spiers on the subject:

 

https://www.jgspiers.com/url-rewrite-responder-citrix-netscaler/

 

This blog uses Storefront as an example, but you can easily apply this concept to your situation.

Link to comment
Share on other sites

Here are the details

I followed https://support.citrix.com/article/CTX221243 article only difference was instead of 302, because I wanted 301 permanent redirect I use Type Respond with below expression

" "HTTP/1.1 301 MOVED PERMANENTLY\r\n" + "Location: https://xyz.jp/corporate" + HTTP.REQ.URL.path_and_query.HTTP_URL_SAFE + "\r\n" + "Connection: close\r\n" + "\r\n""

 

I was able to redirect to https://xyz.jp but not to https://xyx.jp/corporate

 

I need a permanent redirect , please advise 

Link to comment
Share on other sites

 

Assuming that users are sending requests to https://corp.xyz.jp<stuff> and you want to preserve path/query on the new URL structure as https://xyz.jp/corporate<stuff>, then yes you will need the path and query option you used above and I've included below. The HTTP_URL_SAFE or HTTP_HEADER_SAFE should be fine in either case.

 

If the policy isn't working, it may be an issue with the policy expression.

 

1) Using the HTTP responder, you can still use the HTTP Redirect action by changing the default response code from 302 to 301 in the GUI without having to do the custom response.

2) Here's the cli version of either. Add them via CLI and then you can compare in GUI if you prefer:

 

# 301 Moved Permanently

add responder action rs_act_sendtonew301 redirect '"https://xyz.jp/corporate" + HTTP.REQ.URL.PATH_AND_QUERY.HTTP_URL_SAFE' -responseStatusCode 301
add responder policy rs_pol_sendtonew301 'http.req.header("host").set_text_mode(ignorecase).eq("corp.xyz.jp")' rs_act_sendtonew301

 

# 302 Moved Temporarily (default)

add responder action rs_act_sendtonew302 redirect '"https://xyz.jp/corporate" + HTTP.REQ.URL.PATH_AND_QUERY.HTTP_URL_SAFE' -responseStatusCode 302

add responder policy rs_pol_sendtonew302 'http.req.header("host").set_text_mode(ignorecase).eq("corp.xyz.jp")' rs_act_sendtonew302

 

 

Link to comment
Share on other sites

FYI: there is another thread on the same type of redirect here; i posted an example and a few other thoughts for considerations when testing that might apply to your scenario: https://discussions.citrix.com/topic/404189-redirect-requests-for-“wwwoursitecom”-to-“oursitecom”-and-change-url/  (I had some issues in my test lab with browser's caching content and some dns forwarding to the internet messing up the test case; but it just needed some tweaks to get it to the NS where the responder policy did the job.)

 

If you are still having issues, feel free to update and give an example of the policy and action you are trying, and the test urls you are using and what you want the result to be and we'll see if its an issue with the policy or the environment.

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...