Forum Discussion
THawesBPC_28376
May 02, 2017Nimbostratus
Modify HTTP::Host and HTTP::URI in an iRule
I have a need to redirect requests from a subfolder, http://www.website.com/folder/a/b/ for example, to a subdomain of http://folder.website.com/a/b/. I am somewhat able to accomplish this but it doe...
THawesBPC_28376
Nimbostratus
Thanks PK & DevBabu! You were both able to lead me to the solution. I just needed to add one additional piece to solve for website.com/folder instead of website.com/folder/
when HTTP_REQUEST {
if { [HTTP::uri] ends_with "/folder"} {
HTTP::redirect "http://folder.website.com"
}
elseif { [HTTP::uri] starts_with "/folder" && !([HTTP::uri] ends_with "/folder/")} {
set path [HTTP::uri]
set locate [string first "/" $path 1]
set cleanpath [string range $path $locate end]
HTTP::redirect "http://folder.website.com$cleanpath"
}
elseif { [HTTP::uri] starts_with "/folder" && [HTTP::uri] ends_with "/folder/"} {
HTTP::redirect "http://folder.website.com"
}
}
THawesBPC_28376
May 03, 2017Nimbostratus
In that case, this would happen:
http://www.website.com/folder would be redirected to http://folder.website.com/folder, which does not exist.
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