[ad_1]
I have managed to create a simple routing system however I’m a bit stuck on how to make it more dynamic. In this case I have got a blog post set up in my routing which is hard coded. If i click a dynamic link in my website that requires the /views/blog/page.php how can I get the system to work out what the page_slug is and append the page_slug so that it works without hard coding the links into it?
switch ($request) {
case '':
case "https://stackoverflow.com/":
require __DIR__ . '/views/index.php';
break;
case '/blog/blog-post-one':
$_GET['page_slug'] = 'blog-post-one';
require __DIR__ . '/views/blog/page.php';
break;
}
I’ve added my .htaccess file below just in case
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
[ad_2]