.htaccess干净URL的重写规则不起作用

时间:2018-09-30 15:23:40

标签: php .htaccess url-rewriting

我遇到麻烦的

htaccess重写规则。当我在URL(/ page / 1)中输入正确的子弹地址时,出现未定义的变量错误。非常感谢您的帮助。

HTACCESS

RewriteRule ^page/([0-9a-zA-Z]+)$ page.php?id?=$1 [NC,L]

PHP代码:

<?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>

我认为的错误是因为我没有将其放在page.php中,但我不知道如何实现它。

0 个答案:

没有答案
相关问题