if you have a script called index.php that took a parameter called slug…
1 2 3 4 5 6 7 8 9 10 11 |
<?php if (isset($_GET['slug'])) { $sql = "SELECT * FROM `your_table` WHERE slug = ? LIMIT 1"; $smt = $pdo->prepare($sql); $smt->execute(array($_GET['slug'])); $row = $smt->fetchObject(); // do something with the matching record here... } else { // display home page } |
You could then re-write requests using .htaccess:
1 2 |
RewriteEngine on RewriteRule ^(.+)$ index.php?slug=$1 |
Leave a reply