Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Burick/ab2ce2f06de2c44b4332 to your computer and use it in GitHub Desktop.
Save Burick/ab2ce2f06de2c44b4332 to your computer and use it in GitHub Desktop.
<?php
if ($modx->context->key !== 'mgr' ) {
$parts = array_reverse(explode('/', $_SERVER['REQUEST_URI']));
if ($parts[0]) {
$alias = str_replace('.html', '', $parts[0]);
} else {
$alias = $parts[1];
}
if ($res = $modx->getObject('modResource', array('alias' => $alias))) {
$uri = $modx->makeUrl($res->id);
$modx->sendRedirect($uri, array('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