Re-writing a client request from http:// to https://

Many sites are now https only, banking, e-commerce, shopping, and many more. However, end users are not always willing to remember prefixing their request with https:// -- indeed, they never need to as ZXTM and trafficscript provides a simple server solution!

$url = http.getRawURL();
$host = http.getHeader ( "Host");


if( string.regexmatch( $url, "^/foo/(.*)$" ) ) {
    http.sendResponse( "301 Moved Permanently", "text/html", "", "Location: 
https://".$host . $url);
}

This trafficscript will ensure that any http request matching /foo/any/further/path will be re-written as https. So, a customer can request:

http://www.foo.bar/foo/foo/bar/

Yet, their request will be transparently re-written to:

https://www.foo.bar/foo/foo/bar/

Chris Buckley [Zeus Support] 23 August 2006  Permalink 1 comment  

Comments:

This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.

Comment from: mrz [Visitor]
A simpler rule is:

http.changeSite("https://" . http.getHeader ( "Host"));
Permalink 10 August 2008 @ 06:26
Leave a comment ...
Your email address will not be displayed.
Your URL will be displayed.
This public messageboard is not a forum for technical support. To report technical support problems, please contact our dedicated Support team using the instructions at the bottom of this page.
Options:
 
(Line breaks become <br />)
(Set cookies for name, email & url)
Download Free ZXTM Desktop Edition

Recent Articles

Other Resources



www.zeus.com