Php 法尔康路由
你好,对不起我的英语 我的网站结构:Php 法尔康路由,php,routing,phalcon,Php,Routing,Phalcon,你好,对不起我的英语 我的网站结构: https://site.ru/category_1/.../category_N/post.html routes.php: $router = new Phalcon\Mvc\Router(); $router->notFound(array( 'controller' => 'index', 'action' => 'error404', )); $router->add( '/', array(
https://site.ru/category_1/.../category_N/post.html
routes.php:
$router = new Phalcon\Mvc\Router();
$router->notFound(array(
'controller' => 'index',
'action' => 'error404',
));
$router->add(
'/', array(
'controller' => 'index',
'action' => 'index'
)
);
$router->add(
'/{uri:[a-zA-Z0-9\-\/\.]+}', array(
'controller' => 'index',
'action' => 'index',
)
);
$router->add(
'/sitemapsyswrub7g5ox6mtz2tbplwiu6yduox6m.xml', array(
'controller' => 'index',
'action' => 'sitemap'
)
);
return $router;
1) 首先检查site.ru/sitemapsyswrub7g5ox6mtz2tplwiu6yduox6m.xml
2) 下一个检查站
Uri传输到控制器/操作
控制器查找$uri并加载post
3) 下一步检查主页。
site.ru/index.php、site.ru/index.html和site.ru/index.htm已重定向到htaccess文件中的site.ru
它是有效的。
但我有问题。如果url为:
site.ru/blabla_
然后显示错误:
BlablaController handler class cannot be loaded
#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('BlablaControlle...', 2)
#1 [internal function]: Phalcon\Dispatcher->_dispatch()
#2 [internal function]: Phalcon\Dispatcher->dispatch()
#3 /home/srv/http/project/site.ru/public/index.php(23): Phalcon\Mvc\Application->handle()
#4 {main}
如果url为:
site.ru/blabla_.
好的,404
帮助为错误404制定正确的路由。url“sitemapsyswrub7g5ox6mtz2tbplwiu6yduox6m.xml”匹配{uri:[a-zA-Z0-9-/.]+}
移动uri:[a-zA-Z0-9-/.]+}在结束文件路由规则中
范例
$router = new Phalcon\Mvc\Router();
$router->notFound(array(
'controller' => 'index',
'action' => 'error404',
));
$router->add(
'/sitemapsyswrub7g5ox6mtz2tbplwiu6yduox6m.xml', array(
'controller' => 'index',
'action' => 'sitemap'
)
);
$router->add(
'/{uri:[a-zA-Z0-9\-\/\.]+}', array(
'controller' => 'index',
'action' => 'index',
)
);
$router->add(
'/', array(
'controller' => 'index',
'action' => 'index'
)
);
return $router;