PHP slim restfull框架nginx 配置


http://docs.slimframework.com/ 下载地址这个东西很不错,照到官方的例子做

<?php

require 'vendor/autoload.php';

$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
});
$app->run();

访问localhost/index.php/hello/adaaa 怎么都报404错误

后面想了一下,要支持伪静态.

Nginx 设置是

root        /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 
# <Directory> blocks below.
#
<Directory />
    AllowOverride All
    Require all granted
</Directory>

这样再访问:

就有值了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM