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 ?
– Gabriel José de Oliveira
I’m using Slim 4.0. Do you have to activate ssl? I’ll look it up.
– user122195
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
– Gabriel José de Oliveira
But where do I have to type this command? I don’t even know what kind of server 000webhost uses.
– user122195
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]
– Gabriel José de Oliveira
So I’m going to create this file because there’s nothing here.
– user122195
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
– Gabriel José de Oliveira
Let’s go continue this discussion in chat.
– user122195