sanu0074
Новичок
Есть у меня класс Article, я делаю сайт в зоне .рф и хочу кириллические URL. По запросу http://мойсайт.рф/статьи, я хочу чтобы сработал метод index() контроллера Article. Для этого я в файл application\config\routes.php добавил:
В файле application\config\config.php изменил permitted_uri_chars на:
Создал файл application\core\MY_Router.php
Создал файл application\libraries\MY_URI.php:
В корневом файле index.php добавил в начало строку:
В итоге получаю 404. Что я не так сделал? Или что-то упустил?
PHP:
$route[rawurlencode("статьи")] = "article/index";
PHP:
$config['permitted_uri_chars'] = '?A-Za-zА-Яа-я=\s&0-9~%\.:&_\-|@';
PHP:
class MY_Router extends CI_Router {
function _parse_routes() {
$uri = implode('/', $this->uri->segments);
if (isset($this->routes[$uri])) {
return $this->_set_request(explode('/', $this->routes[$uri]));
}
foreach ($this->routes as $key => $val) {
$key = rawurlencode(str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)));
if (preg_match('#^' . $key . '$#', $uri)) {
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) {
$val = preg_replace('#^' . $key . '$#', $val, $uri);
}
return $this->_set_request(explode('/', $val));
}
}
$this->_set_request($this->uri->segments);
}
}
PHP:
class MY_URI extends CI_URI
{
function _filter_uri($str)
{
if ($str != '' AND $this->config->item('permitted_uri_chars') != '')
{
if ( ! preg_match("|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i", rawurlencode($str)))
{
exit('The URI you submitted has disallowed characters.');
}
}
return $str;
}
}
PHP:
setlocale(LC_ALL, 'ru_RU.UTF8');