mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-05-21 10:18:19 +03:00
Добавление правил реврайта для REQUEST_URI(в конфигурации приведен пример сокращения ссылки на запись из личного блога).
This commit is contained in:
parent
42b2416e6a
commit
3399b89eee
|
@ -248,6 +248,11 @@ $config['memcache']['compression'] = true;
|
|||
* Настройки роутинга
|
||||
*/
|
||||
$config['router']['rewrite'] = array();
|
||||
// Правила реврайта для REQUEST_URI
|
||||
$config['router']['uri'] = array(
|
||||
// короткий вызов топиков из личных блогов
|
||||
'~^(\d+)\.html~i' => "blog/\\1.html",
|
||||
);
|
||||
// Распределение action
|
||||
$config['router']['page']['error'] = 'ActionError';
|
||||
$config['router']['page']['registration'] = 'ActionRegistration';
|
||||
|
|
|
@ -76,10 +76,7 @@ class Router extends Object {
|
|||
*
|
||||
*/
|
||||
protected function ParseUrl() {
|
||||
$sReq=preg_replace("/\/+/",'/',$_SERVER['REQUEST_URI']);
|
||||
$sReq=preg_replace("/^\/(.*)\/?$/U",'\\1',$sReq);
|
||||
$sReq=preg_replace("/^(.*)\/\?.*$/U",'\\1',$sReq);
|
||||
|
||||
$sReq = $this->GetRequestUri();
|
||||
self::$sPathWebCurrent = Config::Get('path.root.web')."/".$sReq;
|
||||
|
||||
$aRequestUrl = ($sReq=='') ? array() : explode('/',$sReq);
|
||||
|
@ -90,6 +87,27 @@ class Router extends Object {
|
|||
self::$sActionEvent=array_shift($aRequestUrl);
|
||||
self::$aParams=$aRequestUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Функция выполняет первичную обработку $_SERVER['REQUEST_URI']
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function GetRequestUri() {
|
||||
$sReq=preg_replace("/\/+/",'/',$_SERVER['REQUEST_URI']);
|
||||
$sReq=preg_replace("/^\/(.*)\/?$/U",'\\1',$sReq);
|
||||
$sReq=preg_replace("/^(.*)\/\?.*$/U",'\\1',$sReq);
|
||||
|
||||
/**
|
||||
* Правила Rewrite для REQUEST_URI
|
||||
*/
|
||||
if($aRewrite=Config::Get('router.uri')) {
|
||||
$sReq = preg_replace(array_keys($aRewrite), array_values($aRewrite), $sReq);
|
||||
}
|
||||
|
||||
return $sReq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Выполняет загрузку конфигов роутинга
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue