Skip to content

Instantly share code, notes, and snippets.

@AnatoliyAkhmatov
Last active July 13, 2021 05:51
Show Gist options
  • Save AnatoliyAkhmatov/859c760b641de76c17edb3b73b677fe8 to your computer and use it in GitHub Desktop.
Save AnatoliyAkhmatov/859c760b641de76c17edb3b73b677fe8 to your computer and use it in GitHub Desktop.
$url = strtok($_SERVER['REQUEST_URI'], '?');
$last_char = substr($url, -1);
if ($last_char == '/' && $url != '/') {
$url = substr($url, 0, strlen($url) - 1);
if (!empty($_GET)) {
$url .= '?' . http_build_query($_GET);
}
header('Location: ' . $url, 301);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment