• View Communities
    • Citrix Developer Network
      The place for unfiltered straight talk on Citrix products. Blogs, code downloads, best practices, APIs, and more can all be found here.
    • Citrix Ready Community Verified
      Does it work with Citrix? Application compatibility questions are a thing of the past with the new Citrix Community Verified site.
    • Blogs
      Learn the latest from the Citrix employees who are building application delivery infrastructure technologies.
    • Blogosphere
      The Citrix Blogosphere is a window into the thousands of conversations taking place about Citrix and Application Delivery.
  •  Sign In
NetScaler Developer Network

Rewrite Policy - Redirect HTTP Requests to HTTPS

This article describes how to rewrite web server responses to find all URLs that begin with the string "http" and replace that string with "https".

Summary

The procedure below describes how to create a Rewrite expression that checks web server responses for body URLs that begin with the string http, and replaces that string with the string https. For example, if your web site responses include the URL http://mail.example.com/exchange, you can use this procedure to rewrite this URL as https://mail.example.com/exchange.

First, you add the rewrite action, named replace_https, as shown below:
      *> add rewrite action replace_https replace_all 'HTTP.RES.BODY(100)' '"https://"' -pattern http://

Next, you add the rewrite policy, named replace_http_pol, as shown below:
      > add rewrite policy replace_http_pol TRUE replace_https NOREWRITE

Finally, you globally bind the rewrite policy to put it into effect:
      > bind rewrite global replace_http_pol 1 -type RES_DEFAULT

More Information

Tags

code code Delete
appexpert appexpert Delete
rewrite rewrite Delete
pe pe Delete
policy policy Delete
action action Delete
pattern pattern Delete
replace https replace https Delete
replace body replace body Delete
bind rewrite bind rewrite Delete
add rewrite add rewrite Delete
replace all replace all Delete
http redirect http redirect Delete
policy engine policy engine Delete
how to how to Delete
Enter tags to add to this page:
Please wait 
Looking for a tag? Just start typing.
  1. Oct 23, 2008

    Roel Schreibers says:

    HTTP.RES.BODY(100) means only the first 100 characters within the body will be s...

    HTTP.RES.BODY(100) means only the first 100 characters within the body will be searched and replaced by the Netscaler. This value should sometimes be larger

    All http references are being replaced, most of the times you only need to replace the local VServer references:

    > add rewrite action replace_https replace_all 'HTTP.RES.BODY(10000)' '*https://www.company.com*' -pattern http://www.company.com

    a binding this policy globaly is dangerous; all VServers will execute the policy. Binding it to the VServer is preferable

  2. Nov 10

    Anonymous says:

    If not global bind to which virtual server? Create dummy for port 80?

    If not global bind to which virtual server? Create dummy for port 80?

Add Comment

Related Links