2012-04-28 23 views
0

我想在Mac操作系統上用Slim運行我的第一個應用程序時遇到問題。我已經配置.htaccess文件是這樣的:我怎麼能在mac中爲slim框架配置.htacces

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php [QSA,L] 

而且我在httpd.conf配置加載模塊重寫,我的index.php放置在同一個目錄中的.htaccess文件。

這是我的PHP代碼(我使用PHP 5.3)

<?php            
require 'Slim/Slim.php';       
$app = new Slim();        
$app->get('hello/:name',function($name) {   
    echo 'Hello' .$name;       
});            
$app->run();          
?> 

當我在使用http://localhost/slim/hello/test瀏覽器中運行它,我得到錯誤404

我在做什麼錯?

回答

1

我是索裏我得到了解決問題,我沒有/字符在我的代碼

$app->get('hello/:name',function($name){   
    echo 'Hello' .$name;       
}); 

我是這個代碼

$app->get('/hello/:name',function($name){   
    echo 'Hello' .$name;       
}); 
解決
0

我認爲重寫規則應該是(用「/」開頭的index.php上說,我們要在根目錄下的index.php)

RewriteRule ^(.*)$ /index.php [QSA,L]