Forum Discussion
Ralph_David_201
Nimbostratus
Dec 25, 2017URI to lower case LTM irule issue
Hi Team,
I have a challenge to redirect all uri into lower case. I am able to redirect the URL to lower case but if i type in e.g myweb.net/fR/PAges/DEfauLT.aspx etc it does not redirect to lower c...
nitass
Employee
Dec 25, 2017Redirection should be on F5 side for client requests with Upper case URI to Lower case URI.
e.g.
// config
[root@ve13a:Active:In Sync] config tmsh 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
}
translate-address enabled
translate-port enabled
vs-index 3
}
[root@ve13a:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
if { [HTTP::uri] ne [string tolower [HTTP::uri]] } {
HTTP::respond 301 noserver Location http://[HTTP::host][string tolower [HTTP::uri]]
}
}
}
// test
[root@ve13a:Active:In Sync] config curl -I http://172.28.24.10/fR/PAges/DEfauLT.aspx
HTTP/1.0 301 Moved Permanently
Location: http://172.28.24.10/fr/pages/default.aspx
Connection: Keep-Alive
Content-Length: 0
[root@ve13a:Active:In Sync] config curl -I http://172.28.24.10/fr/pages/default.aspx
HTTP/1.1 404 Not Found
Date: Mon, 25 Dec 2017 08:53:27 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Fri, 15 Apr 2016 03:55:49 GMT
ETag: "418e44-6a-fc825b40"
Accept-Ranges: bytes
Content-Length: 106
Content-Type: text/html; charset=UTF-8
Stanislas_Piro2
Cumulonimbus
Dec 25, 2017I always recommend path-relative absolute URLs when destination page is on the same service as the current page:
when HTTP_REQUEST {
if { [HTTP::uri] ne [string tolower [HTTP::uri]] } {
HTTP::respond 301 noserver Location [string tolower [HTTP::uri]]
}
}
the problem when working with absolute URLs is when a reverse proxy is configured in front of the server with another hostname or scheme, rewriting is required.
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects