Forum Discussion

John_Stevensen's avatar
John_Stevensen
Icon for Nimbostratus rankNimbostratus
Jan 18, 2018

iRule not parsing correctly... hidden spaces?

Pulling hair out on this one.... trying to find a hidden space? Trailing space? Bad juju?

 

When inputting this iRule straight from Notepad++ - I get this nasty bit of NON-HELPFUL information:

 

01070151:3: Rule [/Common/site1.abc.com_redirect2] error: /Common/site1.abc.com_redirect2:1: error: [undefined procedure: When][When HTTP_REQUEST { Switch –glob [string tolower [HTTP::uri]] { “/” {HTTP::redirect "; } “/v2” {HTTP::redirect "; } default { do nothing } } }]

 

The actual iRule is this:

 

When HTTP_REQUEST { Switch –glob [string tolower[HTTP::uri]] { “/” {HTTP::redirect "; } “/v2” {HTTP::redirect "; } default { do nothing } } }

 

Any help is much appreciated.

 

3 Replies

  • I think the notepadd ++ is getting rid of some CR/LF characters.

    Try this for iRule:

    when HTTP_REQUEST {
        switch -glob[string tolower [HTTP::uri]] {
            "/" { 
                HTTP::redirect "http://site1.abc.com/main"
            }
            "/v2" {
                HTTP::redirect "http://site1.abc.com/second/api/v2" 
            }
            default { 
                log0.notice "do nothing"
            }
        }
    } 
    
  • I've removed the capitalisation, semi-colons and for some reason the hyphen used before -glob wasn't the correct character:

    when HTTP_REQUEST {
        switch -glob[string tolower [HTTP::uri]] {
            "/" { 
                HTTP::redirect "http://site1.abc.com/main"
            }
            "/v2" {
                HTTP::redirect "http://site1.abc.com/second/api/v2" 
            }
            default { 
                log0.notice "do nothing"
            }
        }
    }