Hello, I installed auth0 and I have few problems. One is that my rourter.php page does not work. I installed steampixel simple-php-router on my PHP8 server, it does not show any error message but also it does nothing. I can login just when I write full login.php. Can you advice me what to check to solve this problem?
Thank you
<?php
declare(strict_types=1);
// Required stuff
require_once "_inc/config.php";
use Steampixel\Route;
if ($_SERVER['HTTP_HOST'] !== '...') {
die('<p>This quickstart is configured to be run from <a href="http://...">http://...</a>.</p>');
}
Route::add('/', function() use ($sdk) {
require('profile.php');
});
Route::add('/login', function() use ($sdk) {
require('login.php');
});
Route::add('/callback', function() use ($sdk) {
require('callback.php');
});
Route::add('/logout', function() use ($sdk) {
require('logout.php');
});
Route::run();
I don’t know if this reply will be accepted after this length of time, or if it will be useful for the other posters so far on this thread. But in case it’s useful for others in the future, especially those who are following the Auth0 step-by-step guide for PHP, that page is (a the time of writing) missing an important detail.
For the routing to work at all, the system requires a rewrite rule to redirect all requests to the index.php for the routing to be invoked. That’s normally done through a .htaccess file.
DirectoryIndex index.php
# enable apache rewrite engine
RewriteEngine on
# set your rewrite base
# Edit this in your init method too if you script lives in a subfolder
RewriteBase /
# Deliver the folder or file directly if it exists on the server
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Push every request to index.php
RewriteRule ^(.*)$ index.php [QSA]