Created
November 6, 2018 00:34
-
-
Save ru2fac/e47125c8d33d1c2b2af80e632dd4e2e1 to your computer and use it in GitHub Desktop.
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 | |
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Взято тут: https://ilyaut.ru/cheats/to-remove-index-from-url-resources-a-subsidiary-of-the-main/