I'm looking to create my own front controller for a mini project I'm working on. I used someones example that was shared on Stackoverflow which works great but now I'm trying to pass data such as a user ID.
.htaccess
RewriteEngine On
RewriteRule . /front-controller.php [L]
front-controller.php
<?php
switch ($_SERVER['REQUEST_URI']) {
case '/users':
include 'users.php';
break;
case '/user/new':
include 'users-new.php';
break;
default:
include '404.php';
break;
}
What I want to do now is have the value of USERID be passed to users.php as well ($_GET or any other way) from /users/USERID. Does anyone know a good way to approach this?
You can do it in the request body, in the URL (GET), in the headers.