我只希望SanphamController拥有:
MYSITE / sanpham / chitiet /蛞蝓/努尔卡-HOA-PHAP-vuiton.html
到
MYSITE /努尔卡-HOA-PHAP-vuiton.html
我已经解决了它,但我的网站中的所有其他Controller(CartController等等)都不再运行了,它认为控制器是SanPhamController中的一个项目。
这是我的代码
htaccess的:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
在main / config.php中:
'urlManager' => array(
'rules' => array(
'/'=>'site/index',
'<view:(gioi-thieu|huong-dan|hinh-thuc-thanh-toan|dieu-khoan-dich-vu|chinh-sach-dich-vu)>' => 'site/page',
'<action:(lienhe|thanhtoan|dangnhap|dangky|dangxuat)>' => 'site/<action>',
'danh-muc/<slug:.*>'=>'sanpham/danhmuc',
'thuong-hieu/<slug:.*>'=>'sanpham/thuonghieu',
'tim-kiem/<slug:.*>'=>'sanpham/timkiem',
'<slug:.*>' => 'sanpham/chitiet',
'<controller:\w+>/<id:\d+>' => '<controller>/chitiet',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
'urlFormat' => 'path',
'urlSuffix' => '.html',
'showScriptName' => false,
),
答案 0 :(得分:0)
只需在url manager array的顶部添加此规则:
"nuoc-hoa-phap-vuiton"=>"sanpham/chitiet/slug/nuoc-hoa-phap-vuiton"