0
我只想SanphamController從此有:SEO友好的URL在警予1.1
MYSITE/sanpham/chitiet /蛞蝓/努爾卡-HOA-PHAP-vuiton.html
到
MYSITE/nuoc-hoa-phap-vuiton.html
我已經處理了它,但我的站點中的所有其他控制器(CartController等,..)不再運行,它認爲控制器是SanPhamController中的一個項目。
這是我的代碼
的.htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
在主/ 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,
),
nuoc-hoa-phap-vuiton只是一個Model ite在ActionChitiet中。我已經這樣做了,但它與其他控制器名稱混淆。 例如:「mySite/cart/index」不再工作。 如何在檢查它是sanpham/chitiet中的某個項目之前運行yii默認規則? – 2015-04-02 05:44:44
您可以將該規則放在url規則的末尾或用戶定義url規則的末尾(在yii默認規則之前)。 – hamed 2015-04-02 05:47:15
很高興幫助你:) – hamed 2015-04-02 06:13:51