Forum Discussion

azakaria_102538's avatar
azakaria_102538
Icon for Nimbostratus rankNimbostratus
Dec 28, 2013

Smartphone detection

Hi: kindly i need an IRULE that when a smartphone need to access URL www.mysite.com\AAA to redirect it to another link www.mysite.com\BBB

 

thanks for help

 

8 Replies

  • e.g.

     config
    
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar
    ltm virtual bar {
        destination 172.28.20.15:80
        ip-protocol tcp
        mask 255.255.255.255
        pool foo
        profiles {
            http { }
            tcp { }
        }
        rules {
            myrule
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        vs-index 29
    }
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule myrule
    ltm rule myrule {
        when HTTP_REQUEST {
      if { [string tolower [HTTP::uri]] equals "/aaa" } {
        if { [class match -- [string tolower [HTTP::header "User-Agent"]] contains mobile_useragent] } {
          HTTP::respond 302 noserver Location "http://[HTTP::host]/BBB" Connection Close
        }
      }
    }
    }
    root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm data-group internal mobile_useragent
    ltm data-group internal mobile_useragent {
        records {
            iphone { }
        }
        type string
    }
    
     test
    
    [root@ve11a:Active:In Sync] config  curl -I http://172.28.20.15/AAA -H "User-Agent: Apple-iPhone5C1/1001.405"
    HTTP/1.0 302 Found
    Location: http://172.28.20.15/BBB
    Connection: close
    Content-Length: 0
    
    
  • hi: its working in http, but when i try for https it doesnt , i need https://www.mysite.com/aaa to redirect to https://www.mysite.com/bbb is the irule configuration should be change?

     

    thanks

     

  • can you post the virtual server configuration and irule here?

     

    e.g.

     

    tmsh list ltm virtual (virtual server name)

     

    tmsh list ltm pool (pool name)

     

    tmsh list ltm rule (irule name)

     

  • please see the IRULE

     

    when HTTP_REQUEST { if { [string tolower [HTTP::uri]] equals "/ar/e-services" } { if { [class match -- [string tolower [HTTP::header "User-Agent"]] contains Mobile_Datagroup ] } { HTTP::respond 302 noserver Location "https://[HTTP::host]/ar/home" Connection Close } } }

     

  • can you add some logging?

    e.g.

    when HTTP_REQUEST {
      log local0. "client=[IP::client_addr]:[TCP::client_port] host=[HTTP::host] uri=[HTTP::uri]"
      if { [string tolower [HTTP::uri]] equals "/ar/e-services" } { 
        if { [class match -- [string tolower [HTTP::header "User-Agent"]] contains Mobile_Datagroup ] } { 
          HTTP::respond 302 noserver Location "https://[HTTP::host]/ar/home" Connection Close 
        } 
      } 
    }