Forum Discussion

Darren_Walker_2's avatar
Apr 18, 2018

Enable compression of two or more adjacent slashes in a URI into a single slash.

Nginx has a merge_slashes module that will evaluate a URI like "/foo; and change it to "/foo/bar/foobar?slashes=many". But our IIS websites just display the browser URL the way the user input it: Our Google Analytics team sees these as unique pages in GA and want us to catch all adjacent slashes in a request and redirect it to the standard of one slash at a time. My irule tries have lead to redirect loops so I'm asking for someone's time and genius to help me out.

 

2 Replies

  • You might be able to use something like this:

    when HTTP_REQUEST {
        if { [HTTP::uri] contains "//" } {
            set URIquals [split [HTTP::uri] "/"]
            set newURI ""
            foreach qual $URIquals {
                if { $qual ne "" } {
                    append newURI "/" $qual
                }
            }
            HTTP::uri $newURI
        }
    }
    

    I ran a small test using your input string above:

    Before URI: /foo

    After URI: /foo/bar/foobar?slashes=many