php - 干净 URL 的 .htaccess 重写规则不起作用
问题描述
htaccess 重写规则,我遇到了麻烦。当我在 URL (/page/1) 中输入正确的 slug 地址时,我得到未定义的变量错误。非常感谢任何帮助。
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 中,但我不知道如何实现它。
解决方案
推荐阅读
- javascript - 如何通过在 ComponentDidMount() 中调用的函数访问状态集
- pandas - 美丽的汤提取行和数据
- sql - 替代 QUICK SIGHT 中的 CONTAINS 函数
- postgresql - 普希金无法初始化 PostgreSQL 数据库
- unit-testing - Mockito 单元测试 lombok.extern.slf4j @Slf4j 注释日志?
- django - 模板标签未在 HTML 中呈现
- c - 对数计算器
- javascript - Knockout JS 订阅 2 个 observables 的方式是,如果 2 个 observables 中的任何一个发生变化,我只会收到一次通知
- python-3.x - Google 电子邮件 api .docx 损坏
- jmeter - 如何将 .Net 单元测试与 JMeter 集成