的.htaccess停止URL参数 [英] .htaccess stopping URL Parameter
问题描述
我有问题传递参数通过URL,我认为这是关系到.htaccess文件。
I'm having issues with passing a parameter over the url and I think it is related to the .htaccess file.
本页面:
site.com/apprenticeships/current_vacancies
有一个链接到这个网页:
has a link to this page:
site.com/apprenticeships/current_vacancies?id=1
页面我有:
$id = $_GET['id'];
echo $id;
和在.htaccess文件中有这一行的code:
and in the .htaccess file there is this line of code:
RewriteRule ^apprenticeships/([^/\.]+)/?$ content.php?page=$1
在没有呼应出ID回声的页面。有没有人有一个想法,为什么?
The page with the echo in does not echo out the id. Does anyone have an idea why ?
推荐答案
在?什么
是present在重写规则的第二个参数
(即定义了重写的部分),则默认情况下查询字符串替换。你想这两个查询字符串相结合,你可以用 QSA
(查询字符串追加)标志做到这一点。
When ?something
is present in the second argument of RewriteRule
(the part that defines what to rewrite to), then by default the query string is replaced. You want to combine both query strings, and you can do this with the QSA
(query string append) flag.
RewriteRule ^apprenticeships/([^/\.]+)/?$ content.php?page=$1 [QSA,L]
这篇关于的.htaccess停止URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!