Forum Discussion
Redirection of one site to another
Hi,
I needs to redirect only when last string matches as I dont wana redirect whole site.
example below
--->From
existing irule attached with external https vServer. currently its not working
when HTTP_REQUEST { if { [string tolower [HTTP::host]] ends_with "/documents/.pdf" } { HTTP::respond 301 Location "[HTTP::uri]" } }
- youssef1
Cumulonimbus
Hi korai,
try this:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] == "abcsite" && [string tolower [HTTP::host]] ends_with ".pdf" } { HTTP::respond 301 Location "https://xyz/details/overview[HTTP::uri]" } }
It was not working because you use [HTTP::host] in order to check an URI
use [HTTP::host] for check host
and [HTTP::uri] in order to check an uri
so in the irule that i provid you i checked that the host is abcsite and the uri end with ".pdf".
you can add an additional condition in order to validate that the uri begin with "/documents/":
when HTTP_REQUEST { if { ([string tolower [HTTP::host]] == "abcsite") && ([string tolower [HTTP::host]] ends_with ".pdf") && ([string tolower [HTTP::uri]] starts_with "/documents/") } { HTTP::respond 301 Location "https://xyz/details/overview[HTTP::uri]" } }
Regards
- Samir_Jha_52506
Noctilucent
Above iRule has syntax error. I have bit modified iRule and added
function to make condition more easy. you can modify based on requirements.HTTP::path
when HTTP_REQUEST { if {[string tolower [HTTP::path]] equals "/save/samples/documents/chop-employe.pdf"} { HTTP::respond 301 Location "https://newlocation/employee/overview[HTTP::uri]" } }
- Korai_331784
Altostratus
Hi,
Many thanks , I am try to get approval to test this and will update you.
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