Skip to content

Instantly share code, notes, and snippets.

@nerdyworm
Created August 27, 2010 17:37
Show Gist options
  • Save nerdyworm/553789 to your computer and use it in GitHub Desktop.
Save nerdyworm/553789 to your computer and use it in GitHub Desktop.
<?php
function endsWith($haystack,$needle) {
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
$uri = $_SERVER['REQUEST_URI'];
if(is_404() && endsWith($uri, '/')) {
header("HTTP/1.1 301 Moved Permanently" );
header("Location: ".substr($uri, 0, strlen($uri) - 1).".html");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment