导读:
主要实现这样的url : http://localhost:84/site/contact.html 配置方法:在config/main.php中的components数组中添加 //URL管理 urlManager=array( urlFormat=path, showScriptName = false, //去除index.php urlSuffix=.html, //加...
主要实现这样的url : http://localhost:84/site/contact.html
配置方法:在config/main.php中的‘components’数组中添加
//URL管理
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName' => false, //去除index.php
'urlSuffix'=>'.html', //加上.html
'rules'=>array(
'pattern1'=>'route1',
'pattern2'=>'route2',
'pattern3'=>'route3',
),
),
然后创建.htaccess文件设置如下:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php