Why does Slim Framework work on my computer but not on the Internet server?

Asked

Viewed 109 times

2

index php.

<?php require_once"header.php"; ?>

<?php
    use Psr\Http\Message\ResponseInterface as Response;
    use Psr\Http\Message\ServerRequestInterface as Request;
    use Slim\Factory\AppFactory;

    require_once("vendor/autoload.php");

    $app = AppFactory::create();
    $app->addErrorMiddleware(true, true, true);

    $app->get('/', function (Request $request, Response $response, $args) 
    {
        require_once("nav/home.php");
        return $response;
    });
    $app->get('/sobre', function (Request $request, Response $response, $args) 
    {
        require_once("nav/sobre.php");
        return $response;
    });  
    $app->run();
?>

<?php require_once"footer.php";?>

When I access the home page ('/') it works, but when I click "/on" the server does not find the page, the route is not working.

  • you have activated the ssl certificate in your hosting service ? and which version of the slim you are using ?

  • I’m using Slim 4.0. Do you have to activate ssl? I’ll look it up.

  • in my case, as soon as I activated ssl my routes stopped working. I had to change the .htaccess. file here you can find how to configure the web server: http://www.slimframework.com/docs/v4/start/web-servers.html

  • But where do I have to type this command? I don’t even know what kind of server 000webhost uses.

  • you need to edit the file. htaccess which is in the same directory as idenx.php, thus leaving: Rewriteengine On Rewritecond %{REQUEST_FILENAME} ! -f Rewritecond %{REQUEST_FILENAME} ! -d Rewriterule index.php [QSA,L]

  • So I’m going to create this file because there’s nothing here.

  • 1

    probably that file is hidden, you will have to enable option to display hidden files. In the Cpanel file manager there is a configuration option where you can enable this option. https://cliente.ddrhost.com.br/knowledgebase/331/Como-exibir-arquivos-ocultos-htaccess-pelo-Gerenciador-de-Arquivos-no-cPanel.html

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.