在我的测试应用程序中,我试图从url中删除index.php
。我可以像http://localhost/trackstar/
那样访问根页面,而不是http://localhost/trackstar/index.php
,但只要我尝试访问http://localhost/trackstar/project
之类的其他页面或任何其他页面,我总是会在index.php
页面结束。然而开放http://localhost/trackstar/index.php/project
的作品。Yii - 从url中删除index.php - 总是重定向到'index.php'
我正在使用WAMP服务器。配置如下。
启用apache中的重写模块。 配置main
:
'urlManager' => array(
'urlFormat' => 'path',
'rules' => array(
'commentfeed' => array('comment/feed', 'urlSuffix' => '.xml', 'caseSensitive' => false),
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
'showScriptName' => false,
),
项目的根文件夹.htaccess
:
Options +FollowSymlinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
我还添加了在httpd.conf
,虽然不是真的有必要,我认为:
<Directory "c:/wamp/www/TrackStar/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
我已经在.htaccess
尝试了几个额外参数的组合,但我一直在重定向到我的index.php
页面。
任何想法为什么这不起作用?
编辑:
由于我被重定向,在RewriteCond
检查没有成功,换句话说,REQUEST_FILENAME
没有找到目录或文件。也许我的目录结构中有什么东西没有?
的TrackStar\protected\views\project
目录,例如是我试图通过http://localhost/trackstar/project
访问的页面。我的Yii
框架文件位于www
文件夹上方的目录中。
您的网址是否正确生成?或者应用程序将您重定向到index.php? – 2013-10-18 11:10:15
@PeterM:我的浏览器说'http:// localhost/trackstar/project',但我在'index.php'页面。 – user729103
.htaccess是否与index.php位于同一目录中? – CreatoR