Forum Discussion
Assistance with iRule for substitue/redirect - LTM
- Jan 05, 2017
Hi,
what will happen if you directly went to this?
http://testsite2.com/testapp/unsubs/unsubscribe.phptry 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" } }
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_255934Jan 05, 2017
Nimbostratus
I used the second method and the redirection is now successfully working but i get a response like this:
https://testsite2.com/testapp/unsubs/unsubscribe.php
{"status":"BAD_REQUEST","message":"Invalid URL"}
This initial GET is composed like this:
https://testsite2.com/unsubscribe.php?mid=10176&cid=4758131&oid=2&sid=22810&vid=ASmith&r=MC2
It's as if it's not passing the parameters along? I'm just guessing.
Thanks.
- Dvirus_297774Jan 05, 2017
Altocumulus
let's try this:
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_255934Jan 05, 2017
Nimbostratus
Got a response back from the developer and he said it's good to go.
Thanks!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
