htaccess rewrite rule which I am have trouble with. When I put the correct slug address in the URL (/page/1) I get undefined variable errors. Any help most appreciated.
HTACCESS
RewriteRule ^page/([0-9a-zA-Z]+)$ page.php?id?=$1 [NC,L]
PHP code:
<?php
require_once("db.php");
$sql = $conn->prepare("SELECT meta_desc, title, content, url_slug FROM tbl_emp_details WHERE id=?");
$sql->bind_param("i",$_GET["id"]);
$sql->execute();
$result = $sql->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
}
$conn->close();
?>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The HTML5 Herald</title>
<meta name="description" content="<?php echo $row["meta_desc"]?>">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="css/styles.css?v=1.0">
</head>
<body>
<h1><?php echo $row["title"]?></h1>
<div class="content">
<?php echo $row["content"]?>
</div>
The error I think is because I'm not putting this in page.php but I don't know how to implement it.