Forum Discussion
URL needs to be in certain case letters
Hello,
In the URL/application, "WebCenter" is case-sensitive. So if a client hits:
https://qweb.sys.com/webcenter/default or
https://qweb.sys.com/Webcenter/default or
https://qweb.sys.com/WEBCENTER/default or
`
any other upper and lower case mixture of the word "webcenter", we always want the client to be redirected to:
` https://qweb.sys.com/WebCenter/default with a capital "W" and a capital "C".
Any suggestions on a iRule to handle this?
Thank you, Rich
10 Replies
You can try something like this:
when HTTP_REQUEST { if { [HTTP::uri] equals "WebCenter" } { URL is correct case, do nothing" } elseif { string tolower [HTTP::uri] equals "webcenter" } HTTP::redirect "https://qweb.sys.com/WebCenter/default with a capital W and a capital C" } }Or, do you want to just fix it for them?
- Sorry, you should probably use starts_with instead of equals in the if statements.
- Robert_Luechte1
Nimbostratus
You can try something like this:
when HTTP_REQUEST { if { [HTTP::uri] equals "WebCenter" } { URL is correct case, do nothing" } elseif { string tolower [HTTP::uri] equals "webcenter" } HTTP::redirect "https://qweb.sys.com/WebCenter/default with a capital W and a capital C" } }Or, do you want to just fix it for them?
- Robert_Luechte1
Nimbostratus
Sorry, you should probably use starts_with instead of equals in the if statements.
I should have read your question a little close before I responded the first time. Here is an example where the user is redirected with the proper case for WebCenter and includes the rest of the URL. I haven't actually tested this, so there could be some syntax issues.
when HTTP_REQUEST { if { [HTTP::uri] starts_with "WebCenter" } { URL is correct case, do nothing" } elseif { string tolower [HTTP::uri] starts_with "webcenter" } redirect user to the proper case, including the remainter of the URI. The value 10 in the substring command should be the first character of the rest of the URI. HTTP::redirect "https://qweb.sys.com/WebCenter/[substr [HTTP::uri] 10]" } }- Samir_Jha_52506
Noctilucent
Please try this. Hope it will work as per your plan.
when HTTP_REQUEST { if { ( [string tolower [HTTP::uri]] starts_with "/webcenter" ) } { HTTP::redirect https://qweb.sys.com/WebCenter/default } }- DevBabu
Cirrus
Samir, I think this will create a redirection loop. - Samir_Jha_52506
Noctilucent
I agree with ur comments.
- Arie
Altostratus
Am I correct to assume that the origin web server needs to receive the request in the proper case, but that it doesn't really matter from a client-perspective?
If so, I would recommend re-writing the URI regardless of the case of the request. Redirecting does the trick, but it requires another request (i.e. increased overhead) and isn't as clean as a re-rewrite in my opinion. Something like this should do the trick if you want to re-write the request transparently:
when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/webcenter/" } { HTTP::uri "[string map -nocase { "/webcenter/" "/WebCenter/" } [HTTP::path]]" } }(Note - I haven't tested the above code so I hope I didn't make any typos/omissions.)
- nitass
Employee
this is just one of examples.
configuration root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 4 } root@(ve11c)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux ltm rule qux { when HTTP_REQUEST { switch -glob [HTTP::uri] { "/[wW]ebcenter/default" - "/WEBCENTER/default" { Do nothing } "/[wW][eE][bB][cC][eE][nN][tT][eE][rR]/default" { HTTP::redirect "http://[HTTP::host]/WebCenter/default" } default { Do nothing } } } } test [root@ve11c:Active:In Sync] config curl -I http://qweb.sys.com/webcenter/default HTTP/1.1 404 Not Found Date: Sun, 24 May 2015 14:18:07 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT ETag: "41879c-59-2a9c23c0" Accept-Ranges: bytes Content-Length: 89 Content-Type: text/html; charset=UTF-8 [root@ve11c:Active:In Sync] config curl -I http://qweb.sys.com/Webcenter/default HTTP/1.1 404 Not Found Date: Sun, 24 May 2015 14:18:13 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT ETag: "41879c-59-2a9c23c0" Accept-Ranges: bytes Content-Length: 89 Content-Type: text/html; charset=UTF-8 [root@ve11c:Active:In Sync] config curl -I http://qweb.sys.com/WEBCENTER/default HTTP/1.1 404 Not Found Date: Sun, 24 May 2015 14:18:32 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Sun, 09 Feb 2014 08:39:51 GMT ETag: "41879c-59-2a9c23c0" Accept-Ranges: bytes Content-Length: 89 Content-Type: text/html; charset=UTF-8 [root@ve11c:Active:In Sync] config curl -I http://qweb.sys.com/WeBcEnTeR/default HTTP/1.0 302 Found Location: http://qweb.sys.com/WebCenter/default Server: BigIP Connection: Keep-Alive Content-Length: 0
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
