1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-20 01:09:35 +05:30

(feat): implemented basic url router and updated server .htaccess config

This commit is contained in:
2023-11-09 21:06:30 +05:30
parent 7304483e87
commit c21d06a64d
5 changed files with 299 additions and 253 deletions

4
htdocs/.htaccess Normal file
View File

@@ -0,0 +1,4 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1[QSA,L]

43
htdocs/Router.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
$host = $_SERVER['HTTP_HOST'];
$uri = parse_url($_SERVER['REQUEST_URI'])['path'];
$serverRoutes = [
'/' => 'home.php',
'/projects' => 'projects.php',
'/blog' => 'blog.php',
'/contact' => 'contact.php',
];
$devRoutes = [
'/neosubhamoy/htdocs/' => 'home.php',
'/neosubhamoy/htdocs/projects' => 'projects.php',
'/neosubhamoy/htdocs/blog' => 'blog.php',
'/neosubhamoy/htdocs/contact' => 'contact.php',
];
if ($host == "localhost") {
$routes = $devRoutes;
}
else {
$routes = $serverRoutes;
}
function routeTraffictToPages($uri, $routes) {
if(array_key_exists($uri, $routes)) {
require $routes[$uri];
}
else {
error_page(404);
}
}
function error_page($status_code) {
http_response_code($status_code);
require "error/{$status_code}.php";
die();
}
routeTraffictToPages($uri, $routes);
?>

View File

@@ -1042,10 +1042,6 @@ video {
overflow: hidden; overflow: hidden;
} }
.overflow-scroll {
overflow: scroll;
}
.overflow-y-scroll { .overflow-y-scroll {
overflow-y: scroll; overflow-y: scroll;
} }

250
htdocs/home.php Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long