我使用的创建为MySQL查询字符串,并显示结果的搜索。问题是,查询不具有可变每一个搜索是由时间的长度相同。
I'm using a search that create a query string for MySQL and show the result. The thing is that the query doesn't have the same length of variable each time a search is made.
我在想,如果在.htaccess中有可能做出的mod_rewrite取决于我有多少变量扔了。
I was wondering if in .htaccess it's possible to make a mod_rewrite depending on how much variable I throw at it.
results.php?var1=something&var2=something&var3=.....
我得到这个
results/var1/something/var2/something/var3/something...
但请记住,瓦尔的数量可以根据其复选框被搜索表单上的用户检查更换。
But remember that the numbers of vars can change depending on which checkboxes are checked by the user on the search form.
我希望这显然如果不是我会尝试加入更多的例子。
I hope it's clear if not I'll try to add more example.
尝试在你的htaccess文件在你的文档根目录:
Try this in your htaccess file in your document root:
RewriteEngine on
RewriteRule ^results/([^/]+)/([^/]+)(.*)$ /results/$3?$1=$2 [L,QSA]
RewriteRule ^results/$ /results.php [L,QSA,R]
第一条规则将循环,只要有的/ var /某事
对的URI,并不断追加他们在查询字符串。当最后有没有留下更多的对,结果/
被改写为 results.php
。
The first rule will loop as long as there are /var/something
pairs in the URI, and keeps appending them on the query string. When finally there are no more pairs left, the results/
gets rewritten to results.php
.