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
- Cory_50405
Noctilucent
This is your iRule adding in an ends_with .aspx check on the URI:
when HTTP_REQUEST { Check for capital letters in string if { ([string match {[A-Z]} [HTTP::path]] and [[HTTP::uri] ends_with .aspx])} { HTTP::redirect "http://[HTTP::host][string tolower [HTTP::path]][HTTP::query]" } } - cjones_01_13155
Nimbostratus
Thanks for your help, but it seems that rule doesnt change anythign to lowercase.
Examples strings are below.
Current URL: http://stg.sp10.shrm.org/TemplatesTools/Samples/HRForms/Pages/default.aspx
I want it to look like this: http://stg.sp10.shrm.org/templatestools/samples/hrforms/pages/default.aspx
and only do .aspx
- Cory_50405
Noctilucent
Apologies, I misunderstood your requirement. Try this one:
when HTTP_REQUEST { Check for capital letters in string and if ending is .aspx if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::uri] ends_with .aspx])} { set hostname [string tolower [HTTP::host]] set uriname [string tolower [HTTP::uri]] HTTP::redirect "http://$hostname$uriname" } } - cjones_01_13155
Nimbostratus
Tried that one, same result. It doesn't seem to be changing anything to lowercase. I have checked to make sure the rule is executing.
- Cory_50405
Noctilucent
Add a logging statement in to see what gets put in /var/log/ltm:
when HTTP_REQUEST { Check for capital letters in string and if ending is .aspx if { ([string match {[A-Z]} [HTTP::uri]] and [[HTTP::uri] 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
I dont see anything in that log related to the IRULE
- cjones_01_13155
Nimbostratus
I dont see anything in that log related to the IRULE
- Cory_50405
Noctilucent
If you don't see the string "Request is somehost.com/someuri", then the if statement isn't matching. Which either means the URI doesn't contain a capital letter, or doesn't end in .aspx.
- cjones_01_13155
Nimbostratus
This is the only rule I seem to be able to get to work. But it captures more than the .aspx pages. Its doing a 302 for other gets: See below example:
http://stg.sp10.shrm.org/_layouts/1033/ie55up.debug.js?rev=alivXRlfIa6edBLd7Zyixw%3D%3D
when HTTP_REQUEST {
Check if the URI has any capitalized letters if {[string match {[A-Z]} [HTTP::uri]]}{ HTTP::redirect "http://[HTTP::host][string tolower [HTTP::uri]]" } }
- Cory_50405
Noctilucent
That request doesn't end in .aspx. If there's going to be a query at the end of it, perhaps the logic should change to path on patch vice URI. Try this:
when HTTP_REQUEST { Check for capital letters in string and if ending is .aspx 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" } }
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