在我的測試應用程序中,我試圖從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