.htaccess stopping URL Parameter

2019-09-15 10:04发布

I'm having issues with passing a parameter over the url and I think it is related to the .htaccess file.

This page:

site.com/apprenticeships/current_vacancies

has a link to this page:

site.com/apprenticeships/current_vacancies?id=1

on the page I have:

$id = $_GET['id'];
echo $id;

and in the .htaccess file there is this line of code:

RewriteRule ^apprenticeships/([^/\.]+)/?$ content.php?page=$1

The page with the echo in does not echo out the id. Does anyone have an idea why ?

标签: php .htaccess
1条回答
冷血范
2楼-- · 2019-09-15 10:48

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]
查看更多
登录 后发表回答