Joanmi
Joanmi

Reputation: 442

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. 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?

PD: Don't write duplicated because it isn't duplicated, just the title but the questions are differents.

The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. 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();

Upvotes: 1

Views: 1564

Answers (1)

pspatel
pspatel

Reputation: 518

Try to create a .htaccess file in same folder as file.php. 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

Upvotes: 2

Related Questions