I am using this PHP code to redirect any form of UPPERCASE in URI's to lowercase. There are three exceptions: if the URI includes either "adminpanel" or "search" there is no redirect, also if it already is lowercase there is no redirect
Do you see any way to improve the function in PHP?
$trailed = $_SERVER['REQUEST_URI'];
$pos1 = strpos($trailed,"adminpanel");
$pos2 = strpos($trailed,"search");
if ($pos1 === false && $pos2 === false && strlen($trailed) !== strlen(preg_replace('/[A-Z]/', '', $trailed))) {
$trailed = strtolower($trailed);
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://'. $_SERVER["SERVER_NAME"] . $trailed);
exit;
}