Forked from justenj/Redirect plugin to matreshka (event OnPageNotFound)
Created
February 12, 2016 19:06
-
-
Save Burick/ab2ce2f06de2c44b4332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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