gasguirre gasguirre - 5 months ago 11
PHP Question

allow only urls that have a parameter in

so, I have a

url
that redirects to another doing a
Double Meta Refresh (cleans referer)
and I would like to only allow to see the
second url
when the
url comes with a parameter
.

the current setup is:

urlA.php --DMR---> urlB.php


I want to users to be able to see
urlB only if they come from urlA
, but as the referrer is cleaned in the middle I don't think I can check via referrer in
.htacces
for example.

so I was thinking on checking on a parameter, so urlB is only accessible when a special parameter comes, something like:

urlA.php ----DMR---> urlB.php ///NOT POSSIBLE

urlA.php?key=xxxx ----DMR---> urlB.php /// POSSIBLE


thank you in advance.

Answer

Surely if you are passing a GET parameter you can use:

<?php 
if(!isset($_GET["key"]) || $_GET["key"] !== "urlA.php"){
   die("you must come from a certain page" );
}else{
  echo "You came from the right place";
}