Forum Discussion
matt1985_299432
Nimbostratus
Sep 25, 2017Redirect with URI rewrite setting lowercase URI and removing trailing /
Hi,
I am after some assistance. Essentially I have the requirement to change the URI which is passed to the server. i.e. client requests /content/content server gets /site/path/content/content...
Stanislas_Piro2
Cumulonimbus
Sep 25, 2017Hi,
you can try this code:
when HTTP_REQUEST {
Convert path to lowercase and remove first and last /. prepend a / (to prevent "/" removed)
use path instead of uri to prevent query string blocking path transformation.
the general behavior when converting to lower case is to keep query string case
set new_path "/[string trim [string tolower [HTTP::path]] "/"]"
Add /site/path if starting with /content
if {$new_path starts_with "/content/"} { set new_path "/site/path$new_uri" }
Append query string if exists
if {[HTTP::query] ne ""} {set new_uri $new_path?[HTTP::query]} else {set new_uri $new_path}
if { $new_uri ne [HTTP::uri] } {
if the new path is different to request path, redirect to new uri
HTTP::redirect $new_uri
}
}
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