What I need:
example.com/webpage/
should redirect to example.com/webpage
I am using:
$path = $_SERVER['REQUEST_URI'];
if(substr($path, -1) == '/')
{
$path=rtrim( $path, '/\\' );
header("Location: $path");
}
The problem:
When someone requests the homepage (with or without trailing slash), the value of $path
becomes '/'
and it causes a loop. Can anyone offer me a better solution?