Created
October 19, 2018 18:58
-
-
Save matdave/f136f9024028a6d04406644c6ac19be3 to your computer and use it in GitHub Desktop.
Evo to Revo URI Plugin
This file contains hidden or 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 | |
/** | |
** OnPageNotFound | |
**/ | |
$URI = $_SERVER['REQUEST_URI']; | |
if(strpos($URI, '.html') !== false){ | |
$URI = ltrim(str_replace('.html','/',$URI), '/'); | |
$resource = $modx->getObject('modResource', array('uri:='=>$URI, 'context_key:='=> $modx->context->key)); | |
if(!empty($resource)){ | |
$modx->sendRedirect($modx->makeUrl($resource->id, $modx->context->key, '', 'full'), 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); | |
} | |
}else{ | |
$URI = ltrim($URI, '/').'.html'; | |
$resource = $modx->getObject('modResource', array('uri:='=>$URI, 'context_key:='=> $modx->context->key)); | |
if(!empty($resource)){ | |
$modx->sendRedirect($modx->makeUrl($resource->id, $modx->context->key, '', 'full'), 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment