我正在使用在Yii 1.1上编写的网站,Web服务器是apache 2。目前我必须解决以下问题:
有 URL,每个 URL 都呈现模块。1) example.com/index.php/library2) example.com/index.php/sys
如何将这些 URL 更改为
1) example.com/library2) example.com/sys
这就是我如何从 URL 索引.php?
谢谢!
在 Url Manger 的 Yii 框架页面中有解释
您需要做三件事才能在apache server
中实现这一目标。
1) 在apache conf
文件中启用url_rewriting
2) 使用此.htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
3) 在main.php
中配置网址管理器
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:'w+>/<id:'d+>' => '<controller>/view',
'<controller:'w+>/<action:'w+>/<id:'d+>' => '<controller>/<action>',
'<controller:'w+>/<action:'w+>' => '<controller>/<action>'),
1)首先将其包含在虚拟主机的设置中: AllowOverride All
2)并添加以下行:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)'?*$ index.php/$1 [L,QSA]
3) 在配置/主.php中:
urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>**false**