Forum Discussion
Lowercase URI
Below I have the current rule setup: when HTTP_REQUEST {
Check for capital letters in string if {[string match {[A-Z]} [HTTP::path]]}{
HTTP::redirect "http://[HTTP::host][string tolower [HTTP::path]][HTTP::query]"
} }
This is working and converting the string to all lowercase. I want the rule to only do pages or strings that end in .aspx?
Can this be done
47 Replies
- cjones_01_13155
Nimbostratus
Yeah not sure. Its not matching the .aspx it looks like since we know the A-Z will work. Its not showing anything in the logs.
- Cory_50405
Noctilucent
What is the exact host and URI are you testing with?
- cjones_01_13155
Nimbostratus
This is a shrarepoint site.
The host is stg.sp10.shrm.org
when you hit the url it returns http://stg.sp10.shrm.org/Pages/default.aspx
sharepoint adds the /pages/default.aspx.
- Cory_50405
Noctilucent
What if you change the 'ends_with' to 'contains' in the if statement? Any behavioral change?
- cjones_01_13155
Nimbostratus
Tried this: when HTTP_REQUEST { if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::path] contains ".aspx"])} { set hostname [string tolower [HTTP::host]] set uriname [string tolower [HTTP::uri]] log local0. "Request is $hostname$uriname" HTTP::redirect "http://$hostname$uriname" } }
no luck. Still loading capital letters
- cjones_01_13155
Nimbostratus
It doesnt seem to match on the if statement [[HTTP::path] ends_with ".aspx"])} {
Can we change it to any incoming url that ends_with .aspx be redirected to lowercase?
- Cory_50405
Noctilucent
The latest iRule that I posted above should do that. But it will only do the redirect if there's a capital letter somewhere in the URI. Otherwise, no redirection will happen.
- cjones_01_13155
Nimbostratus
With this Irule in place. The following URL does not become lowercase http://stg.sp10.shrm.org/LegalIssues/EmploymentLawAreas/Pages/default.aspx
You can see that it has a capital L,E and P
when HTTP_REQUEST { if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::path] ends_with ".aspx"])} { set hostname [string tolower [HTTP::host]] set uriname [string tolower [HTTP::uri]] log local0. "Request is $hostname$uriname" HTTP::redirect "http://$hostname$uriname" } } - cjones_01_13155
Nimbostratus
Could we try if it contains "Pages" in the URI?
- Cory_50405
Noctilucent
Do you have other iRules applied to the virtual server in question? I see no reason why this isn't matching if you are accessing it using the FQDN you just specified.
- cjones_01_13155
Nimbostratus
Looks just like this. The rule worked before we tried to add the ends_with part.
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