require_once "slim/vendor/autoload.php";$app = new \Slim\Slim(['debug' => true,'mode' => 'development']);$app->get("/index", function() { echo "Hello Slim World
";});$app->run();
在本機訪問localhost/api.php/index有輸出,但是在Ubuntu上居然是404 not found,這是為什嗎?
ps:這個架構資源也少。。。
回複內容:
require_once "slim/vendor/autoload.php";$app = new \Slim\Slim(['debug' => true,'mode' => 'development']);$app->get("/index", function() { echo "Hello Slim World
";});$app->run();
在本機訪問localhost/api.php/index有輸出,但是在Ubuntu上居然是404 not found,這是為什嗎?
ps:這個架構資源也少。。。
找到了原因,因為未設定偽靜態
#nginxroot /Users/jackluo/Works/php/rest; location / { root /Users/jackluo/Works/php/rest; index index.html index.php; try_files $uri $uri/ /index.php?$args; }#apache【1】啟動mod_rewrite——去掉#,#代表注釋LoadModule rewrite_module modules/mod_rewrite.so【2】修改AllowOverride None為AllowOverride All## Deny access to the entirety of your server's filesystem. You must# explicitly permit access to web content directories in other # blocks below.# AllowOverride All Require all granted
slim架構還是不錯的,用起來挺有感覺的。http://dighash.com/ 一個簡單的slim demo~