Forum Discussion

Vivek_Padale_16's avatar
Vivek_Padale_16
Icon for Nimbostratus rankNimbostratus
Aug 01, 2014

Irule for lowercase

Hello,

 

i want to create a irule for lowercase string for a specific url. Below is the irule which i am trying but i am not getting the result.The current version on client side is v11.3 .

 

when HTTP_REQUEST { if {[string match {[A-Z]} [HTTP::uri] eq "myBlock.Profile.com/Pages"]}{ HTTP::redirect "http://[HTTP::host][string tolower [HTTP::uri]]" } }

 

Thank you.

 

7 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    How about this?

    when HTTP_REQUEST {
     if {[string match {[A-Z]} [HTTP::uri] eq "myBlock.Profile.com/Pages"]}{ 
       set uri [string tolower [HTTP::uri]]
       HTTP::redirect "http://[HTTP::host]$uri" 
     }
    }
    

    Rgds

    N

  • What are you trying to match with the first URI check? This expression doesn't make sense to me:

    if {[string match {[A-Z]} [HTTP::uri] eq "myBlock.Profile.com/Pages"

    Also, you need to use wildcards in the string match to check for any capital letter:

    % string match {[A-Z]} AAA
    0
    % string match {*[A-Z]*} AAA
    1
    

    So maybe something like this?

    when HTTP_REQUEST {
     if {"[HTTP::host][HTTP::uri]" eq "myBlock.Profile.com/Pages"]}{ 
       HTTP::redirect "myblock.profile.com/pages"
     }
    }
    

    Aaron

  • Hii,

     

    The above irules are not working properly.... So i tried something like this way.....

     

    when HTTP_REQUEST { if {[HTTP::host] eq "abfluat.abfsg.com"]}{ HTTP::redirect "http://[HTTP::host][string tolower [HTTP::path]]?[HTTP::query]" } }

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    You've got an extra square brace on the 2nd line.

    Also, http::path and http::query is, in effect, http::uri so why not try this?

    when HTTP_REQUEST { 
       if {[HTTP::host] eq "abfluat.abfsg.com"}{
         set uri [string tolower [HTTP::uri]]
         HTTP::redirect "http://[HTTP::host]$uri"
      } 
    }
    

    Rgds Nathan

  • what about this one?

     config
    
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
    ltm virtual bar {
        destination 172.28.24.10:0
        ip-protocol tcp
        mask 255.255.255.255
        pool foo
        profiles {
            http { }
            tcp { }
        }
        rules {
            qux
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        translate-port disabled
        vs-index 60
    }
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux
    ltm rule qux {
        when RULE_INIT {
      set static::uri "/myBlock.Profile.com/Pages"
      set static::uri_lower [string tolower $static::uri]
    }
    when HTTP_REQUEST {
      set uri [HTTP::uri]
      set uri_lower [string tolower $uri]
      if { $uri_lower eq $static::uri_lower } {
        if { $uri ne $uri_lower } {
          HTTP::redirect "http://[HTTP::host]$uri_lower"
        }
      }
    }
    }
    
     test
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/myBlock.Profile.com/Pages
    HTTP/1.0 302 Found
    Location: http://172.28.24.10/myblock.profile.com/pages
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.24.10/myblock.profile.com/pages
    HTTP/1.1 404 Not Found
    Date: Wed, 06 Aug 2014 14:38:41 GMT
    Server: Apache/2.2.3 (CentOS)
    Content-Type: text/html; charset=iso-8859-1
    
  • Hello Guys, thanks for all responses. I had come up with a irule which is working properly..

     

    when HTTP_REQUEST { if { [HTTP::host] equals "www.joe.com" and [HTTP::uri] starts_with "/net/myjoe" } { HTTP::redirect "http://[HTTP::host][string tolower [HTTP::uri]]" } }