Yii URL重写删除index.php不起作用

时间:2015-08-18 05:54:06

标签: yii url-rewriting

你好我试图从yii项目中删除index.php。我已经安装了wamp 2.4 x64并在我的根路径上启用了mod_rewrite apache模块和.htaccess文件,如下所示

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
我的主配置文件main.php中的

和url manager数组是

 'urlManager' => array(
        'urlFormat' => 'path',
        'showScriptName' => false,
        'caseSensitive' => false,
        'rules' => array(
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
            '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
        ),
    ),

但只有在我包含index.php的情况下才能使用url,建议会提前感谢

1 个答案:

答案 0 :(得分:0)

很可能是因为您的应用程序在子目录下而不是在根文件夹中运行,例如http://localhost/myapp/

在这种情况下,您还需要在htaccess中指定RewriteBase

RewriteBase /myapp/

之后

RewriteEngine on

根据实际路径更改上面的路径。

相关问题