SEO友好网址在yii 1.1

时间:2015-04-02 05:02:22

标签: yii friendly-url yii-url-manager

我只希望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,
),

1 个答案:

答案 0 :(得分:0)

只需在url manager array的顶部添加此规则:

"nuoc-hoa-phap-vuiton"=>"sanpham/chitiet/slug/nuoc-hoa-phap-vuiton"