Forum Discussion

Rajesh_74831's avatar
Rajesh_74831
Icon for Nimbostratus rankNimbostratus
Aug 19, 2014

Need to delete extra "/" in the URI

Hi Guys,

    Our developers found an issue where the page is getting 404 error when there is an additional "/" at the end of the page. So I am thinking of an irule which would remove the additional "/" at the end of the uri, following is what I am tried and getting a TLS error, can you please suggest me how can I get this working.

when HTTP_REQUEST { if { [HTTP::uri] ends_with "/" } { HTTP::uri [[HTTP::uri] string map {"/" ""}] } }

Following is the error that I received

Aug 18 23:26:38 tmm err tmm[8726]: 01220001:3: TCL error: /Common/log-uri - invalid command name "/" while executing "[HTTP::uri] string map {"/ " " "} "

Please let me know what is the cause for the failure.

Thanks

-Rajesh

  • Hi Rajesh,

    Here is the iRule you need, your problem was on "string map".

    when HTTP_REQUEST { 
        if { [HTTP::uri] ends_with "/" } { 
                HTTP::uri [string map {"/" ""} [HTTP::uri]] 
        } 
    }
    
  • Hi,

     

    I suggest you to use this example code below :

     

    when HTTP_REQUEST {
        if { [HTTP::uri] ends_with "/" } {
            HTTP::uri [string trimright [HTTP::uri] "/"]
        }
    }