Forum Discussion
dwhite12_255934
Jan 05, 2017Nimbostratus
Assistance with iRule for substitue/redirect - LTM
Web developer would like this behavior:
so if a GET request is made to 'testsite2.com/unsubscribe.php[?params¶ms]'
it should be forwarded to https://testsite2.com/testapp/unsubs/unsubscribe....
- Jan 05, 2017
Hi,
what will happen if you directly went to this?
http://testsite2.com/testapp/unsubs/unsubscribe.php
try this:
when HTTP_REQUEST { if { [HTTP::host] equals "testsite2.com" && [HTTP::uri] starts_with "/unsubscribe.php" } { HTTP::respond 301 noserver Location "/testapp/unsubs/unsubscribe.php" } }
OR
when HTTP_REQUEST { if { [HTTP::host] equals "testsite2.com" && [HTTP::uri] starts_with "/unsubscribe.php" } { HTTP::redirect "http://testsite2.com/testapp/unsubs/unsubscribe.php" } }
SELECTED ANSWER - This will keep your parameters and will only replace the url:
when HTTP_REQUEST { if { [HTTP::host] equals "testsite2.com" && [HTTP::uri] starts_with "/unsubscribe.php" } { set uri [string map {"/unsubscribe.php" "/testapp/unsubs/unsubscribe.php"} [HTTP::uri]] HTTP::redirect "http://[HTTP::host]$uri" } }
Dvirus_297774
Altocumulus
Hi,
what will happen if you directly went to this?
http://testsite2.com/testapp/unsubs/unsubscribe.php
try this:
when HTTP_REQUEST {
if { [HTTP::host] equals "testsite2.com" && [HTTP::uri] starts_with "/unsubscribe.php" } {
HTTP::respond 301 noserver Location "/testapp/unsubs/unsubscribe.php"
}
}
OR
when HTTP_REQUEST {
if { [HTTP::host] equals "testsite2.com" && [HTTP::uri] starts_with "/unsubscribe.php" } {
HTTP::redirect "http://testsite2.com/testapp/unsubs/unsubscribe.php"
}
}
SELECTED ANSWER - This will keep your parameters and will only replace the url:
when HTTP_REQUEST {
if { [HTTP::host] equals "testsite2.com" && [HTTP::uri] starts_with "/unsubscribe.php" } {
set uri [string map {"/unsubscribe.php" "/testapp/unsubs/unsubscribe.php"} [HTTP::uri]]
HTTP::redirect "http://[HTTP::host]$uri"
}
}
dwhite12_255934
Jan 05, 2017Nimbostratus
Got a response back from the developer and he said it's good to go.
Thanks!
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