的.htaccess停止URL参数参数、htaccess、URL

由网友(一笑奈何)分享简介:我有问题传递参数通过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/appr...

我有问题传递参数通过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]
阅读全文

相关推荐

最新文章