Forum Discussion
Irule ending with trailing slash
I have requirement that If URL is referring to a page that does not end with a "/" then redirect to the same URL ending with a "/" but it should not include below points:
1. ignore all request with Method POST
2. ignore all URLs starting with:
/WebResource.axd
/EPiServer.Forms/
3. URLs containing :
a query in the URL (indication is “?”)
URLs containing: /api/
- Kevin_StewartEmployee
Perhaps something like this:
when HTTP_REQUEST { if { not ( [HTTP::uri] ends_with "/" ) && \ not ( [HTTP::method] eq "POST" ) && \ not ( [HTTP::uri] starts_with "/Webresources.axd" ) && \ not ( [HTTP::uri] starts_with "/EPiServer.Forms/" ) && \ not ( [HTTP::uri] contains "?" ) && \ not ( [HTTP::uri] contains "/api/" ) } { HTTP::redirect "https://[HTTP::host][HTTP::uri]/" } }
- Ambk25Nimbostratus
Hi Kevin,
Thnk you very much for your reply. We have also created below irule ( with one more requirment --- If any letter in the URL contains upper case then redirect to a strict lower case version of the same URL):
when HTTP_REQUEST {
if { [HTTP::uri] ne [string tolower [HTTP::uri]] } { HTTP::respond 301 noserver Location [string tolower [HTTP::uri]] }
if { not ( [HTTP::uri] ends_with "/" ) and ! ([class match [string tolower [HTTP::path]] ends_with /DMZ/extensions]) and (! ([HTTP::uri] contains "/api/") or ! ([HTTP::uri] contains "/WebResource.axd") or !([HTTP::uri] contains "/EPiServer.Forms/") or !([HTTP::uri] contains "?") )} { HTTP::respond 307 Location "[HTTP::uri]/" }
}In this irule we want to ignore all post method request which should not redirect, so let us know how we can achive this condition.
- Kevin_StewartEmployee
when HTTP_REQUEST { if { [HTTP::uri] ne [string tolower [HTTP::uri]] } { HTTP::redirect "https://[HTTP::host][string tolower [HTTP::uri]]" } elseif { not ( [HTTP::uri] ends_with "/" ) && \ not ( [HTTP::method] eq "POST" ) && \ not ( [HTTP::uri] starts_with "/Webresources.axd" ) && \ not ( [HTTP::uri] starts_with "/EPiServer.Forms/" ) && \ not ( [HTTP::uri] contains "?" ) && \ not ( [HTTP::uri] contains "/api/" ) } { HTTP::redirect "https://[HTTP::host][HTTP::uri]/" } }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com