Skip to content

Instantly share code, notes, and snippets.

@krasnikovdev
Last active March 29, 2018 18:11
Show Gist options
  • Save krasnikovdev/fb57875ed23ca0689c491f5d2d045bdd to your computer and use it in GitHub Desktop.
Save krasnikovdev/fb57875ed23ca0689c491f5d2d045bdd to your computer and use it in GitHub Desktop.
//Плагин
case "OnHandleRequest":
$alias = $_REQUEST['q'];
$exceptions = array('robots.txt', 'sitemap.xml');
if (in_array($alias, $exceptions)) {
return;
}
/* Включить, если будут требовать сеошники
$pattern = array("«", "»", ";", "(", ")", "$", "№", ",");
$url_1 = str_replace($pattern, '', $alias);
if (strcmp($alias, $url_1)) {
$url_2 = '//' . $_SERVER['HTTP_HOST'] . '/' . $url_1;
$modx->sendRedirect($url_2);
}
*/
if ($alias != '') {
$end_sumbol = substr($alias, -1);
if ($end_sumbol != '/') {
$url = '//' . $_SERVER['HTTP_HOST'] . '/' . $alias . '/';
$modx->sendRedirect($url);
return;
}
$alias_lower = mb_strtolower($alias);
if (strcmp($alias, $alias_lower) != '0') {
$url_lower = '//' . $_SERVER['HTTP_HOST'] . '/' . $alias_lower;
$modx->sendRedirect($url_lower);
}
}
break;
#htaccess
RewriteMap lc int:tolower
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment