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
Tried that one.
Doesn't seem to be changing anything to lowercase.
http://stg.sp10.shrm.org/TemplatesTools/Pages/default.aspx
- Cory_50405
Noctilucent
Is anything being logged in var/log/ltm?
- cjones_01_13155
Nimbostratus
nothing related to the Irule.
- Cory_50405
Noctilucent
I think I missed quotes around the extension:
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" } } - cjones_01_13155
Nimbostratus
That didn't seem to help. Still capital letters.
- Cory_50405
Noctilucent
You need to investigate why the if statement isn't matching. The iRule should work once the condition gets matched.
- cjones_01_13155
Nimbostratus
Maybe Im making it meor complicated than it should be. All I want to do is any incoming url that ends with .apsx redirected to lower case.
- Cory_50405
Noctilucent
This iRule will do that:
when HTTP_REQUEST { if { [[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
Getting the belwo error now.
un 17 11:20:40 SHRM-LB2 err tmm3[9168]: 01220001:3: TCL error: /Common/Set_lowercase2 - invalid command name "/Pages/default.aspx" while executing "[HTTP::path] ends_with ".aspx"" Jun 17 11:20:40 SHRM-LB2 err tmm2[9167]: 01220001:3: TCL error: /Common/Set_lowercase2 - invalid command name "/Pages/default.aspx" while executing "[HTTP::path] ends_with ".aspx"" Jun 17 11:20:43 SHRM-LB2 err tmm1[9166]: 01220001:3: TCL error: /Common/Set_lowercase2 - invalid command name "/Pages/default.aspx" while executing "[HTTP::path] ends_with ".aspx""
- Cory_50405
Noctilucent
Redirect loop. So we can't eliminate the uppercase character check. Need to figure out why this one isn't working:
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" } }
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