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
Comments (2)
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
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