jonathanw84
Jun 03, 2020Cirrus
Solved
iRule to Add Trailing Slash Except for Extensions
Hello,
I have an iRule that I am using to direct requests to a specific pool based on the URI:
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if {[HTTP::uri] starts_with "/apps"}...
- Jun 04, 2020
Hello,
Considering that the resource will only have the dot char to extensions, I do this way:
when HTTP_REQUEST { if { not ( [HTTP::path] ends_with "/") && not ( [URI::basename [HTTP::uri]] contains "." ) } { # Append slash and keep querystring when it exists HTTP::uri [HTTP::path]/[expr { "[URI::query [HTTP::uri]]" eq {} ? {} : "?[URI::query [HTTP::uri]]" }] } if { [string tolower [HTTP::uri]] starts_with "/apps" } { pool ProxyPass_DEV_pool_2 } else { pool ProxyPass_DEV_pool_1 } }
Where:
- "/apps" will become "/apps/" internally;
- "/apps?param=value" will become "/apps/?param=value" internally;
- "/test.html" and "/test.html?param=value" remais the same.
I hope it helps.
Regards