2013-08-22 44 views
0

我正在使用作曲家和yii的項目。我會告訴你一些關於環境的信息。我不明白爲什麼.htaccess適用於其他機器,但不適用於我的。我認爲這是我的問題=)。我希望有一個人可以幫助我。.htaccess和刪除index.php的一些麻煩

  • 文件夾
  • 我的虛擬主機
  • .htaccess文件
  • 警予配置
  • 一些東西
  • 日誌

文件夾

該項目有THI小號文件夾:

~/Development/www/project/    - Project 
~/Development/www/project/app   - Yii's index.php 
~/Development/www/project/app/.htaccess - ... 
... 
... 

虛擬主機

這裏我的虛擬主機。我只是把DocumentRoot,DirectoryIndex和ServerName。足夠。

NameVirtualHost *:80 
<VirtualHost *:80> 
    ServerName project 
    DirectoryIndex index.php 
    DocumentRoot /Users/simonegentili/Development/Www/project/app 
</VirtualHost> 

的.htaccess

這是我們的.htaccess文件(我們是因爲我與其他開發商合作)。這適用於其他團隊成員的Linux環境。不要使用MacOsX在我的機器上工作。我不認爲這個問題是由於MacOsX造成的,但我認爲這個問題是由於我的配置不好造成的。因此,...這裏是我們的.htaccess。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php 

Yii的配置

這是我的配置文件。

return array(
    'components' => array(
     'urlManager' => array(
      'urlFormat' => 'path', 
      'showScriptName' => false, 
      'caseSensitive' => false, 
     ), 
    ), 
); 

的東西...

的問題是,如果我繼續showScriptName爲true,所有的工作文件,但我看到這樣的URL的 「http://項目/ index.php文件/網站/指數」 。當URL成爲 「HTTP://項目/網站/指數」 我得到這個錯誤:

Not Found 

The requested URL /site/index was not found on this server. 

日誌

最後,在這裏我的日誌。我只是得到404錯誤代碼。爲什麼!?!?!?

127.0.0.1 - - [22/Aug/2013:12:05:34 +0200] "GET /site/index HTTP/1.1" 404 208 
[Thu Aug 22 12:05:34 2013] [error] [client 127.0.0.1] File does not exist: ~/Development/Www/project/app/site, referer: http://project/index.php/site/index 

PS。你會發現這個引用是「http://project/index.php/site/index」首先我在瀏覽器上打開「http://project/index.php/site/index」,然後我改變配置文件並刷新頁面。

有人可以幫助我!

回答

0

我認爲你缺少你URLManager規則改成這樣:

'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>', 
     ), 
    ), 
+0

感謝,但這不是解決了的東西。 – sensorario