-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Options -Indexes | ||
RewriteEngine on | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
#RewriteRule ^ - [R=404,L] | ||
#RewriteRule ^ - [R=403,L] | ||
|
||
#ErrorDocument 404 | ||
#ErrorDocument 403 | ||
|
||
|
||
#level One | ||
RewriteRule ^test-([\w\d~%.:_\-]+)$ test?param=$1 [NC] | ||
RewriteRule ^test-([\w\d~%.:_\-]+)/([\w\d~%.:_\-]+)$ test?param=$1&another=$2 [NC] | ||
|
||
#level Two | ||
RewriteRule ^moda-page-([\w\d~%.:_\-]+)$ moda-page?param=$1 [NC] | ||
RewriteRule ^moda-page-([\w\d~%.:_\-]+)/([\w\d~%.:_\-]+)$ test?param=$1&another=$2 [NC] | ||
|
||
RewriteRule (.+) index.php [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
class Router { | ||
private $routes = []; | ||
|
||
// Add a route and associate it with a page name and callback | ||
public function addRoute($url, $pageName, $callback) { | ||
$this->routes[$url] = ['page' => $pageName, 'callback' => $callback]; | ||
} | ||
|
||
// Handle the current request and execute the associated code | ||
public function handle($requestUri) { | ||
foreach ($this->routes as $url => $route) { | ||
if ($url === $requestUri) { | ||
call_user_func($route['callback']); | ||
return; | ||
} | ||
} | ||
|
||
// Handle 404 - Page not found | ||
include 'pages/404.php'; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
// Include the router file | ||
require_once 'router.php'; | ||
|
||
// Initialize the router | ||
$router = new Router(); | ||
|
||
// Define routes and associate them with page names | ||
$router->addRoute('/', 'home', function () { | ||
// Code for the Home page | ||
include 'pages/home.php'; | ||
}); | ||
|
||
$router->addRoute('/about', 'about', function () { | ||
// Code for the About page | ||
include 'pages/about.php'; | ||
}); | ||
|
||
$router->addRoute('/contact', 'contact', function () { | ||
// Code for the Contact page | ||
include 'pages/contact.php'; | ||
}); | ||
|
||
// Handle the current request | ||
$router->handle($_SERVER['REQUEST_URI']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
error_reporting(1); | ||
// Include the router file | ||
require_once 'router.php'; | ||
|
||
// Initialize the router | ||
$router = new Router(); | ||
|
||
// Define routes and associate them with page names | ||
$router->addRoute('/', 'home', function () { | ||
// Code for the Home page | ||
include 'pages/home.php'; | ||
}); | ||
|
||
$router->addRoute('/about', 'about', function () { | ||
// Code for the About page | ||
include 'pages/about.php'; | ||
}); | ||
|
||
$router->addRoute('/contact', 'contact', function () { | ||
// Code for the Contact page | ||
include 'pages/contact.php'; | ||
}); | ||
|
||
// Handle the current request | ||
$router->handle($_SERVER['REQUEST_URI']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Page Not Found</title> | ||
</head> | ||
<body> | ||
<h1>404 - Page Not Found</h1> | ||
<p>The page you are looking for does not exist.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>About Page</title> | ||
</head> | ||
<body> | ||
<h1>About Us</h1> | ||
<p>Learn more about our company and our team.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Contact Page</title> | ||
</head> | ||
<body> | ||
<h1>Contact Us</h1> | ||
<p>Feel free to get in touch with us using the contact information provided.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Home Page</title> | ||
</head> | ||
<body> | ||
<h1>Welcome to the Home Page</h1> | ||
<p>This is the content for the home page.</p> | ||
</body> | ||
</html> |