...

View Full Version : Prevent Url Variables that arent in use



thekevin07
01-06-2008, 04:37 AM
Hi

Does anyone know how to prevent people from putting unused variables in a page. For example if you go to http://google.com/?a=a it gives a 404 error. I'd like to do the same or do a 301 redirect.

thanks

Pennimus
01-06-2008, 11:09 PM
Here's a bit of PHP I use. It redirects ALL query strings to the equivalent URL without the query string though, so if you want to allow some, you'll need to tinker with it. Perhaps by having an array of "safe" values that can be used. Should be a good start point though.



$requested = $_SERVER['REQUEST_URI'];
if (strpos($requested, '?') > 0){
$uri_array = explode('?', $requested);
$redirect = 'http://www.yourdomain.com'.$uri_array[0];
header("HTTP/1.0 301 Moved Permanently");
header("Location: $redirect");
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum