Thanks guys, but I think I found a better solution, @KingCrunch suggested a solution that I expanded and converted it to a function. the function below can delete or cancel any URI variable without using the hackers used. I am sending it as it can help someone.
function unset_uri_var($variable, $uri) { $parseUri = parse_url($uri); $arrayUri = array(); parse_str($parseUri['query'], $arrayUri); unset($arrayUri[$variable]); $newUri = http_build_query($arrayUri); $newUri = $parseUri['path'].'?'.$newUri; return $newUri; }
now consider the following uri
index.php?properties&status=av&page=1 //To remove properties variable $url = unset_uri_var('properties', basename($_SERVER['REQUEST_URI'])); //Outputs index.php?page=1&status=av //To remove page variable $url = unset_uri_var('page', basename($_SERVER['REQUEST_URI'])); //Outputs index.php?properties=&status=av
hope this helps someone. and thanks @KingKrunch for your decision :)
source share