<?php
$uri = preg_replace("/?.*/i",'', $_SERVER['REQUEST_URI']);
if (strlen($uri)>1) {// если не главная страница...
if (rtrim($uri,'/')!=$uri) {
header("HTTP/1.1 301 Moved Permanently");
header('Location: http://'.$_SERVER['SERVER_NAME'].str_replace($uri, rtrim($uri,'/'), $_SERVER['REQUEST_URI']));
exit();
}
}
?>