0

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.

I was wondering if in .htaccess it's possible to make a mod_rewrite depending on how much variable I throw at it.

Instead of having this in the URL

results.php?var1=something&var2=something&var3=.....

I get this

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.

4

1 回答 1

1

在文档根目录的 htaccess 文件中尝试此操作:

RewriteEngine on
RewriteRule ^results/([^/]+)/([^/]+)(.*)$ /results/$3?$1=$2 [L,QSA]
RewriteRule ^results/$ /results.php [L,QSA,R]

只要/var/somethingURI 中有对,第一条规则就会循环,并不断将它们附加到查询字符串中。当最终没有更多对时,将results/被重写为results.php.

于 2012-08-31T14:42:11.780 回答