Forum Discussion

Kiran_125879's avatar
Kiran_125879
Icon for Nimbostratus rankNimbostratus
Apr 23, 2013

iRule for uri rewrite only for selected uri paths and keep the same url for all other cases

Hi Friends,

 

 

Could anyone please suggest me an iRule which will only rewrite uris for selected uri paths and keep the original url same for all other cases.

 

ex: I want the uris to be rewritten only for the below 2 cases and all other cases should be kept as is.

 

domain.com/abc -> domain.com/hij

 

domain.com/def -> domain.com/klm

 

 

All other request should be same such as if the original request is domain.com/123 -> it should remain same as domain.com/123

 

 

Any help would be greatly appreciated.

 

 

Regards

 

Kiran

 

1 Reply

  • e.g.

    [root@ve10:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.252:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve10:Active] config  b pool foo list
    pool foo {
       members 200.200.200.101:80 {}
    }
    [root@ve10:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       switch [string tolower [HTTP::uri]] {
          "/abc" { HTTP::uri "/hij" }
          "/def" { HTTP::uri "/klm" }
       }
    }
    }
    
     /abc
    
    [root@ve10:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.251(50703) <-> 172.28.19.252(80)
    1366693438.9012 (0.0010)  C>S
    ---------------------------------------------------------------
    GET /abc HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: domain.com
    
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(50703) <-> 200.200.200.101(80)
    1366693438.9033 (0.0018)  C>S
    ---------------------------------------------------------------
    GET /hij HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: domain.com
    
    ---------------------------------------------------------------
    
     /something else
    
    [root@ve10:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.251(50704) <-> 172.28.19.252(80)
    1366693465.1440 (0.0009)  C>S
    ---------------------------------------------------------------
    GET /somethingelse HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: domain.com
    
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(50704) <-> 200.200.200.101(80)
    1366693465.1451 (0.0010)  C>S
    ---------------------------------------------------------------
    GET /somethingelse HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Accept: */*
    Host: domain.com
    
    ---------------------------------------------------------------