I restructed my website in a kind of modular way.
For my self written web apps I have a sub folder structure.
Now my central entry point on top level has routes to manage different URLs.
The redirect to the sub level index.php pages work great.
As my web apps in the sub directories have own index.php pages, when redirecting to them from the top level index.php page, my included files on top level site are gone.
Of course the includes on top level stay if i just include the individual pages/views from the sub level application. But then all the logic in the sub level index.php files is not used and the sub level apps cannot be considered standalone anymore.
So my question is: Is it possible to keep the includes on my top level index.php page when redirecting (header("location: ...")) to a sub level application index.php?
Here is my folder structure: Folder structure
Here is my code of the top level index.php:
<?php
const DS = DIRECTORY_SEPARATOR;
define("PATH", $_SERVER["DOCUMENT_ROOT"] . DS);
require_once PATH . "config.php";
include_once "Route.php";
include_once PATH_VIEWS . "header.php";
include_once PATH_VIEWS . "banner.php";
if($_SESSION["loggedIn"]) include_once PATH_VIEWS . "menu.php";
// Routes
Route::add("/", function(){
// Check Session
if(!$_SESSION["loggedIn"]){
// Goal: Redirect to module / sub site "sso" while keeping
// the included header.php and banner.php
header("location:/login");
exit();
}
include PATH_VIEWS . "welcome.php";
});
Route::add("/login", function(){
header("location: /apps/sso/");
exit();
});
Route::run();