douhe2305 2018-09-30 15:23
浏览 22

.htaccess重写规则,干净的URL无法正常工作

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100