.htaccess 重写通过所有查询字符串 [英] .htaccess rewrite pass all query strings through
本文介绍了.htaccess 重写通过所有查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我使用:
RewriteRule ^([^/\.]+)/?$ page.php?page=$1 [L]
这在传递一个查询字符串时很有用.
Which is good for when passing one querystring through.
但是有没有办法只传递所有查询字符串?即一页请求可能是:
But is there a way just to pass all querystrings through? i.e. One page request might be:
domain.com/contact?course=23
另一个可能是:
domain.com/contact?workshop=41
所以我需要知道查询字符串名称是什么,但一次只会传入一个
So I need to know what the query string name is, but only ever one will be passed in at a time
推荐答案
如果我正确理解您的问题,您只需添加 [QSA]
(查询字符串追加)标志到RewriteRule
If I understand your question correctly, you can just add the [QSA]
(query string append) flag to the end of your RewriteRule
RewriteRule ^([^/\.]+)/?$ page.php?page=$1 [L,QSA]
这将像您已经完成的那样处理您的请求,并在末尾添加任何进一步的查询字符串参数.
This will process your request as you've already done, and add any further querystring params onto the end.
这篇关于.htaccess 重写通过所有查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文