【发布时间】:2013-02-11 08:25:43
【问题描述】:
这是我的默认动态链接:
www.example.com/news/index.php?id=5&title=Test-Title-3
这是htaccess重写的链接:
www.example.com/news/5/Test-Title-3
现在我希望用 PHP 获取 id 变量(即 5)和/或 title 变量(即 Test-Title-3)。
我尝试过使用$_GET['id'] 但返回
index.php/Test-Title-3
或使用 $_GET['title'] 什么都不返回。知道如何获取变量吗?
(已编辑) 这是我的 .htaccess 文件,以备不时之需:
Options +FollowSymLinks Options All -Indexes
<files .htaccess>
order allow,deny
deny from all
</files>
RewriteEngine on
RewriteRule (.*)/(.*)/ index.php?id=$1&title=$2
【问题讨论】:
-
你需要在 RewriteRule (.*)/(.*)/index.php?id=$1&title=$2 [QSA] 末尾添加 [QSA] 标志
-
嘿,谢谢!它有效,我觉得错过那个标志真的很愚蠢