Home > Backend Development > PHP Tutorial > php框架 - php slim框架路由找不到

php框架 - php slim框架路由找不到

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:22:43
Original
1321 people have browsed it

<code class="php">require_once "slim/vendor/autoload.php";
$app = new \Slim\Slim(['debug' => true,'mode' => 'development']);
$app->get("/index", function() {
    echo "<h1>Hello Slim World</h1>";
});
$app->run();</code>
Copy after login
Copy after login

在本机访问localhost/api.php/index有输出,但是在Ubuntu上居然是404 not found,这是为什么?
ps:这个框架资源也少。。。

回复内容:

<code class="php">require_once "slim/vendor/autoload.php";
$app = new \Slim\Slim(['debug' => true,'mode' => 'development']);
$app->get("/index", function() {
    echo "<h1>Hello Slim World</h1>";
});
$app->run();</code>
Copy after login
Copy after login

在本机访问localhost/api.php/index有输出,但是在Ubuntu上居然是404 not found,这是为什么?
ps:这个框架资源也少。。。

找到了原因,因为未设置伪静态

<code class="php">#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></directory>
    AllowOverride All
    Require all granted
</directory>    </code>
Copy after login

slim框架还是不错的,用起来挺有感觉的。http://dighash.com/ 一个简单的slim demo~

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template