Forum Discussion
Korai_331784
Altostratus
May 31, 2018Redirection 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 i...
youssef1
Cumulonimbus
May 31, 2018Hi 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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