Forum Moderators: phranque
<?php
$mydir=getdir("/",$_SERVER['REQUEST_URI']);
if($mydir!=false)
{
$thedomain = 'http://' . $_SERVER['SERVER_NAME'];
header("HTTP/1.1 301 Moved Permanently");
header( 'Location: ' . $thedomain.$mydir );
}
function getdir($loc,$tfile)
{
$startloc=$_SERVER['DOCUMENT_ROOT'];
if (file_exists($startloc.$loc) && $handle = opendir($startloc.$loc))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != ".." && strncasecmp($loc.$file,$tfile,strlen($loc.$file))==0)
{
if(strncasecmp($loc.$file,$tfile,strlen($tfile))==0)
{
return $loc.$file;
}
else
{
return getdir($loc.$file."/",$tfile);
}
}
}
closedir($handle);
}
return false;
}
?> [edited by: incrediBILL at 9:00 pm (utc) on Apr 21, 2013]
[edit reason] URL removed, see forum charter and site TOS for posting rules [/edit]