Skip to content

Instantly share code, notes, and snippets.

@bendasvadim
Created January 2, 2019 12:30
Show Gist options
  • Save bendasvadim/21e3807e4bee5827ace39070f89a942e to your computer and use it in GitHub Desktop.
Save bendasvadim/21e3807e4bee5827ace39070f89a942e to your computer and use it in GitHub Desktop.
Плагин для переадресации с url с UpperCase на LoverCase
<?php
/**
* Плагин для переадресации с url с UpperCase на LoverCase
*/
$eventName = $modx->event->name;
switch($eventName) {
case 'OnHandleRequest':
if($modx->context->get('key') != "mgr"){
if(isset($_GET['rewrite-strtolower-url'])) {
$url = $_GET['rewrite-strtolower-url'];
unset($_GET['rewrite-strtolower-url']);
$params = http_build_query($_GET);
if(strlen($params)) {
$params = '?' . $params;
}
$modx->sendRedirect('http://' . $_SERVER['HTTP_HOST'] . '/' . strtolower($url) . $params, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
}
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment