Skip to content

Instantly share code, notes, and snippets.

@Pathologic
Created October 7, 2019 15:11
Show Gist options
  • Save Pathologic/464521f7a52e4a78432ea79475c0f151 to your computer and use it in GitHub Desktop.
Save Pathologic/464521f7a52e4a78432ea79475c0f151 to your computer and use it in GitHub Desktop.
rertert
<?php
if ($modx->event->name == 'OnWebPagePrerender') {
$_url = parse_url($_SERVER['REQUEST_URI']);
if($modx->resource->isfolder && !preg_match("/\/$/", $_url['path'])) {
$id = $modx->resource->id;
$url = isset($_url['query']) ? $modx->makeUrl($id, '', $_url['query']) : $modx->makeUrl($id);
$modx->sendRedirect($url, ['responseCode' => 'HTTP/1.1 301 Moved Permanently']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment