2013-08-22 47 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