$redirect_url = $modx->makeUrl(337); //337 is id of destination page where you want unwanted folk directed to
$present_url = $_SERVER['HTTP_REFERER']; //where user is coming from
$site_url = $modx->config['site_url']; //your site's full url
$worldpay_url = "".$site_url."worldpay.html"; //url of worldpay to be matched
if ($present_url !== $worldpay_url) // if referring url does not match worldpay.html...
{
$modx->sendRedirect($redirect_url); // ...please get lost, go to page 337
die();
}Are you looking for something like this? Try and see what happensCreate this snippet, check_url and call it in download.html, [[!check_url]]. Alter the url names inside...$redirect_url = $modx->makeUrl(337); //337 is id of destination page where you want unwanted folk directed to $present_url = $_SERVER['HTTP_REFERER']; //where user is coming from $site_url = $modx->config['site_url']; //your site's full url $worldpay_url = "".$site_url."worldpay.html"; //url of worldpay to be matched if ($present_url !== $worldpay_url) // if referring url does not match worldpay.html... { $modx->sendRedirect($redirect_url); // ...please get lost, go to page 337 die(); }
Note, although the common user would suffer this redirection mandate, an advanced user can fake his or her referring url.
$site_url = $modx->config['www.myurl.com']; //your site's full url $worldpay_url = "".$site_url.".worldpay.com"; //url of worldpay to be matched
In the original snippet, please do not change anything except line 4, worldpay.html ....everything else must be intact.$site_url = $modx->config['www.myurl.com']; //your site's full url $worldpay_url = "".$site_url.".worldpay.com"; //url of worldpay to be matched
<?php
$redirect_url = $modx->makeUrl(337);
$present_url = $_SERVER['HTTP_REFERER']; //user's referring URL
//now looking for https://secure-test.worldpay.com, if it is not found, user is kicked out.
if (strpos($present_url,'https://secure-test.worldpay.com') === false) {
$modx->sendRedirect($redirect_url);
die();
}
?>but still doesn't display the correct page if redirected from worldpay.Let us disable a few things. This code should spit out the exact URL of the page you are coming from; then from there you can see what's going on, and make changes accordingly.
<?php
//$redirect_url = $modx->makeUrl(337);
$present_url = $_SERVER['HTTP_REFERER'];
//if (strpos($present_url,'https://secure-test.worldpay.com') === false) {
//$modx->sendRedirect($redirect_url);
//die();
// }
echo $present_url; //will display url of the worldpay referring page