Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ru2fac/e47125c8d33d1c2b2af80e632dd4e2e1 to your computer and use it in GitHub Desktop.
Save ru2fac/e47125c8d33d1c2b2af80e632dd4e2e1 to your computer and use it in GitHub Desktop.
<?php
switch ($modx->event->name) {
case 'OnWebPagePrerender':
$modx->resource->_output = str_replace('"index/', '"', $modx->resource->_output);
break;
case 'OnPageNotFound':
$uri = explode('?', $_SERVER['REQUEST_URI']);
if ($res = $modx->findResource('index' . $uri[0])) {
$modx->sendForward($res);
}
break;
case 'OnHandleRequest':
if (strpos($_SERVER['REQUEST_URI'], 'index/') !== false) {
$url = str_replace('index/', '', $_SERVER['REQUEST_URI']);
$modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
break;
default:
break;
}
return;
@ru2fac
Copy link
Author

ru2fac commented Nov 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment