【问题标题】:404 not found Slim Framework404 未找到 Slim 框架
【发布时间】:2018-05-30 09:19:26
【问题描述】:

您好,我在 url/v2/api/domain/file.php 文件夹中有文件,但是当我尝试执行 url/data/1, url/v2/api/domain/data /2。说: 404 not found 但如果我把 url/v2/api/domain/file.php/data/1 格式似乎不同并出现: Page Not Found 有人可以看到错误吗?

PD:不要写重复,因为它不是重复的,只是标题但问题不同。

找不到您要查找的页面。检查地址栏 以确保您的 URL 拼写正确。如果一切都失败了,你可以 通过以下链接访问我们的主页。

访问主页

代码:

<?php
require 'vendor/autoload.php';
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;

$app = new \Slim\App;
$app->get('data/{name}', function (ServerRequestInterface $request, ResponseInterface $response, $args) {
    // Use the PSR 7 $request object

    return $response->write("Hello, " . $args['name']);
});
$app->run();

【问题讨论】:

    标签: php slim slim-3


    【解决方案1】:

    尝试在与 file.php 相同的文件夹中创建一个 .htaccess 文件。该文件的内容是

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

    那么希望你可以在没有file.php的情况下访问页面

    【讨论】:

    • hm 例如,我正在尝试 url/v2/api/domain/1,它显示“在此服务器上找不到请求的 URL /v2/api/domain/1。”但是现在,如果我输入praktikum.secra/v2/api/index.php/domain/1,它会正确显示值,但我不想引入“index.php”
    • 是的,所以要删除 index.php,您必须在 .htaccess 上方创建
    猜你喜欢
    • 2018-09-14
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    • 2016-01-01
    • 2018-05-26
    • 1970-01-01
    相关资源
    最近更新 更多