Forum Discussion
iRule assistance for subfolder redirect
Hi All,
iRule newbie here. I have a URL "https://blog.example.com/oldsubfolder/FBAR" that I would like redirected to "https://blog.example.com/newsubfolder/FBAR".
I tried using the below iRule but it doesn't preserve whats appended after the subfolder. Any assistance would be greatly appreciated.
when HTTP_REQUEST {
if { !([HTTP::host] starts_with "https://blog.example.com/oldsubfolder/") } {
HTTP::redirect "https://[HTTP::host]/newsubfolder/"
}
}
Hello,
in this attempt I'm using the getfield command to split URI by "/oldsubfolder/" string, so that first "oldsubfolder" match would be field 1 and the rest of your URI will be field 2.
I'm replacing /oldsubfoler/ with new path manually and then appending the rest of your uri using field 2 syntax.
when HTTP_REQUEST { if { [HTTP::uri] contains "/oldsubfolder/"} { HTTP::redirect https://[HTTP::host]/newsubfolder/[getfield [HTTP::path] "/oldsubfolder/" 2] } }
I haven't had the chance to test this in a lab, please do before installing.
Hello,
in this attempt I'm using the getfield command to split URI by "/oldsubfolder/" string, so that first "oldsubfolder" match would be field 1 and the rest of your URI will be field 2.
I'm replacing /oldsubfoler/ with new path manually and then appending the rest of your uri using field 2 syntax.
when HTTP_REQUEST { if { [HTTP::uri] contains "/oldsubfolder/"} { HTTP::redirect https://[HTTP::host]/newsubfolder/[getfield [HTTP::path] "/oldsubfolder/" 2] } }
I haven't had the chance to test this in a lab, please do before installing.
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