如何将example.com/index.php/lib更改为example.com/lib?

时间:2014-12-05 06:01:49

标签: php apache yii

我正在使用在Yii 1.1上编写的网站,网络服务器是apache 2。 目前我必须解决以下问题:

有URL,每个都有模块。 1)example.com/index.php/library 2)example.com/index.php/sys

如何将这些网址更改为

1)example.com/library 2)example.com/sys

那我怎么能从URL中获取index.php?

谢谢!

2 个答案:

答案 0 :(得分:1)

Yii Framework page in Url Manger

中对此进行了解释

您需要在apache server中完成三件事。

1)在url_rewriting文件中启用apache conf

2)使用此.htaccess

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

3)在main.php

中配置urlmanager
'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 :(得分:0)

1)首先将其包含在虚拟主机的设置中: AllowOverride All

2)并添加以下内容:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

3)在config / main.php中:

urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>**false**
相关问题