Forum Discussion

Jeremy_Dorrough's avatar
Jeremy_Dorrough
Icon for Nimbostratus rankNimbostratus
Jan 25, 2007

trailing slash

Could someone please help me create an irule that will add a forward slash to the end of a url if not already there?

 

 

https://www.somesite.com/directory --> https://www.somesite.com/directory/

 

 

thanks in advance for any input

1 Reply

  • Give this a shot:

    when HTTP_REQUEST {
      if { !([HTTP::uri] ends_with "/") } {
        HTTP::uri "[HTTP::uri]/"
      }
    }

    Now, keep in mind that this will append a slash to ALL URI's that don't end with a slash - including files with extensions/etc. If you want to mask them out then you might want to combine this with a matchclass or switch statement to mask out the uri's that you don't want to append a slash to.

    -Joe