重写url并让更多参数

时间:2013-02-18 12:29:48

标签: php .htaccess get rewrite

我正在重写这种网址

http://deia.info/category/calendar/10/

/index.php?task=browse_posts&catid=$2

通过.htaccess中的此代码

RewriteRule ^category/(.+)/(.+) /index.php?task=browse_posts&catid=$2

似乎做了这个工作。问题是当发送其他参数时,会忽略这些参数。

例如:

http://deia.info/category/calendar/10/?start_date=10

isset($_GET['start_date'])不会返回真实

为什么?

1 个答案:

答案 0 :(得分:1)

当传入的URL包含OP示例中的查询时:

http://deia.info/category/calendar/10/?start_date=10

将其与/替换为替换网址中的新查询的方式相加(附加)方法是添加QSA Flag

所以添加[L,QSA],就像这样:

RewriteRule ^category/(.+)/(.+) /index.php?task=browse_posts&catid=$2 [L,QSA]
相关问题