yii 1.1 中的 SEO 友好 url
SEO friendly url in yii 1.1
我只想让 SanphamController 从这里获得:
mySite/sanpham/chitiet/slug/nuoc-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
在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,
),
只需在 url 管理器数组的顶部添加此规则:
"nuoc-hoa-phap-vuiton"=>"sanpham/chitiet/slug/nuoc-hoa-phap-vuiton"
我只想让 SanphamController 从这里获得:
mySite/sanpham/chitiet/slug/nuoc-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
在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,
),
只需在 url 管理器数组的顶部添加此规则:
"nuoc-hoa-phap-vuiton"=>"sanpham/chitiet/slug/nuoc-hoa-phap-vuiton"