Forum Discussion
Irule ending with trailing slash
Hi Kevin,
Thanks for your response. We have tested this and fulfilling our requirement but only one problem.
We want to ignore all post method request which should not redirect for first condition i.e. upper to lower case redirection. That means all post methods should not convert to lower case and should not get trail slash. So let us know how we can achieve this condition in existing irule.
when HTTP_REQUEST {
if { ( [HTTP::method] ne "POST" ) and ( [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]/"
}
}- Ambk25Nov 15, 2022
Nimbostratus
Hi Kevin,
This logic works for us and now we have tested below irule as per the requirement:
when HTTP_REQUEST {
if { ( [HTTP::method] ne "POST" ) and ( [HTTP::uri] contains "*/Webresources.axd" ) }
{
HTTP::redirect "https://[HTTP::host][HTTP::uri]]"} elseif { not ( [HTTP::uri] ends_with "/" ) && \
not ( [HTTP::method] eq "POST" ) && \
not ( [HTTP::uri] contains "/EPiServer.Forms/" ) && \
not ( [HTTP::uri] contains "?" ) && \
not ( [HTTP::uri] contains "/api/" ) && \
not ([class match [string tolower [HTTP::path]] ends_with /DMZ/extensions])
} {
HTTP::respond 301 Location "https://[HTTP::host][string tolower [HTTP::uri]]/"
}
}Now we have additional condition which needs to be complete: If trailing slash and upper case is present then it needs to be redirect to lower case with trailing slash
Example: www.abc.com/vgh-BT-grt/ needs to be redirect to www.abc.com/vgh-bt-grt/
Please help us to fulfil this requirement by modifying above mentioned irule.
- Kevin_StewartNov 15, 2022
Employee
when HTTP_REQUEST { if { ( [HTTP::method] ne "POST" ) and ( [HTTP::uri] contains "*/Webresources.axd" ) } { HTTP::redirect "https://[HTTP::host][HTTP::uri]]" } elseif { not ( [HTTP::uri] ends_with "/" ) && \ not ( [HTTP::method] eq "POST" ) && \ not ( [HTTP::uri] contains "/EPiServer.Forms/" ) && \ not ( [HTTP::uri] contains "?" ) && \ not ( [HTTP::uri] contains "/api/" ) && \ not ( [class match [string tolower [HTTP::path]] ends_with /DMZ/extensions] ) } { HTTP::respond 301 Location "https://[HTTP::host][string tolower [HTTP::uri]]/" } elseif { ( [HTTP::uri] ends_with "/" ) && ( [HTTP::uri] ne [string tolower [HTTP::uri]] ) } { HTTP::respond 301 Location "https://[HTTP::host][string tolower [HTTP::uri]]" } }- Ambk25Dec 06, 2022
Nimbostratus
Hi Kevin,
Thanks for your update but unfortunately it did not worked and getting multiple redirections with infinite loops to meet below condition:
"If trailing slash and upper case is present then it needs to be redirect to lower case with trailing slash"
Could you please suggest any other way by modifying previusly shared irule to meet our requirement.
Again, thank you very much for your unconditional support and prompt response.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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