简体   繁体   English

找不到404 Slim Framework

[英]404 not found Slim Framework

Hello I have the file on the folder url/v2/api/domain/ file.php but when I try to do url/data/1, url/v2/api/domain/data/2. 您好,我在url / v2 / api / domain / file.php文件夹中有该文件,但是当我尝试执行url / data / 1,url / v2 / api / domain / data / 2时。 Say: 404 not found but if I put url/v2/api/domain/file.php/data/1 the format seems diferent and appear: Page Not Found Someone can see the mistake? 说:找不到404,但是如果我输入url / v2 / api / domain / file.php / data / 1,则格式似乎不同并出现:页面未找到有人可以看到错误吗?

PD: Don't write duplicated because it isn't duplicated, just the title but the questions are differents. PD:不要写重复的内容,因为它不是重复的,只是标题,但问题有所不同。

The page you are looking for could not be found. 找不到您要查找的页面。 Check the address bar to ensure your URL is spelled correctly. 检查地址栏,确保您的URL拼写正确。 If all else fails, you can visit our home page at the link below. 如果所有其他方法均失败,则可以通过以下链接访问我们的主页。

Visit the Home Page 访问主页

Code: 码:

<?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();

Try to create a .htaccess file in same folder as file.php. 尝试在与file.php相同的文件夹中创建一个.htaccess文件。 The content of the file are 该文件的内容是

RewriteEngine On

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

Then hopefully you can access the page without file.php 然后希望您可以在没有file.php的情况下访问该页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM