Forum Discussion

Denizor_21773's avatar
Denizor_21773
Icon for Nimbostratus rankNimbostratus
Sep 08, 2011

scape backslash redirect

Hi guys,

 

 

 

I´m making some redirects but i have a problem with scape backslash

 

 

 

 

 

Exemplo:

 

 

 

 

 

if { [matchclass [HTTP::uri] starts_with $::redirectURIs] } {

 

HTTP::respond 301 "Location" "http://x.xxxxxx.com/"

 

}

 

 

 

class redirectURIs {

 

/Book\index.aspxNOT WORK

 

/KKKKKKKKKKKK/index.aspx REDIRECT PERFECT

 

 

 

 

 

 

 

if I put a backslash does not work (/Book "\" index.aspx). Can someone help me?

 

 

 

A Santos

 

3 Replies

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus
    Why do you want to use a backslash? In HTTP it's forward slashes (Depending on which RFC you're reading, but certainly in the original RFC's it's explicitly excluded).

     

     

    Backslashes are usually used for an escape character (e.g. \n is linefeed, \f form feed etc).

     

     

    Like you said forward slash works fine.

     

     

    H
  • A couple of other tips:

     

     

    For IIS, make sure to set the URI to lowercase before looking it up in the datagroup. And set the URIs in the datagroup to lowercase as well.

     

     

    In v9.4.4+ remove the $:: prefix from the datagroup name, redirectURIs, to preserve CMP compatibility:

     

    http://devcentral.f5.com/wiki/iRules.cmpcompatibility.ashx

     

     

    And try using the class match command instead of matchclass as the latter has been deprecated:

     

    http://devcentral.f5.com/wiki/iRules.class.ashx

     

     

    Aaron
  • IIS will accept backslashes by the way. You can probably escape the backslash either using \\ or \\\ in the datagroup.

     

     

    $ curl -I 'http://www.microsoft.com/en-us\default.aspx'

     

     

    HTTP/1.1 200 OK

     

    Cache-Control: no-cache

     

    Pragma: no-cache

     

    Content-Length: 206535

     

    Content-Type: text/html; charset=utf-8

     

    Expires: -1

     

    Server: Microsoft-IIS/7.5

     

    X-AspNet-Version: 2.0.50727

     

    Set-Cookie: MS0=de0af0d22bf6459a92445994b95a86ee; domain=microsoft.com; expires=Thu, 08-Sep-2011 23:34:35 GMT; path=/

     

    Set-Cookie: MC1=GUID=270d68692f2ef34f92487726f2582b6f&HASH=6968&LV=20119&V=3; domain=microsoft.com; expires=Wed, 08-Sep-2021 23:04:35 GMT; path=/

     

    Set-Cookie: MS_WT=ta_MSCOM_1={"Value":"{\"_wt.control-327131-ta_MSCOM_1\":{\"value\":\"{\\\"runid\\\":\\\"353624\\\",\\\"testid\\\":\\\"353616\\\",\\\"trackid\\\":\\\"353625\\\",\\\"typeid\\\":\\\"1\\\"}\"},\"_wt.user-327131\":{\"value\":\"{\\\"currentPath\\\":\\\"327131-ta_MSCOM_1-353624-353625\\\",\\\"uid\\\":\\\"4828298231037768320\\\",\\\"userSession\\\":\\\"1315523075284-13155230752844128\\\"}\"}}","Expires":"\/Date(1323299075578)\/"}; domain=microsoft.com; expires=Wed, 07-Dec-2011 23:04:35 GMT; path=/

     

    VTag: 27946130900000000

     

    P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"

     

    X-Powered-By: ASP.NET

     

    Date: Thu, 08 Sep 2011 23:04:34 GMT

     

     

    Aaron