.htaccess从搜索查询中动态重写GET变量

时间:2012-12-12 14:38:24

标签: php .htaccess rewrite

我的网站上有以下网址:

  

www.domain.com/index.php?id=42&f_su_ort=PLZ%2C+Ort+oder+Name+der+Einrichtung&f_sop_name=Name+der+Einrichtung&f_sop_traeg=0&f_su_ent=10&f_sp_111 = ON&安培; f_sp_121 = ON&安培; f_sp_131 = ON&安培; f_sp_141 = ON&安培; f_sp_151 = ON&安培; f_sp_161 = 0&安培; f_sp_112 = 112安培; f_sp_211 = ON&安培; f_sp_221 = ON&安培; f_sp_231 = ON&安培; f_sp_241 = ON&安培; f_sp_251 = ON&安培; f_sp_212 = ON&安培; f_sp_213 = ON&安培; f_sp_222 = ON&安培; f_sp_223 = ON&安培; f_sp_232 = ON&安培; f_sp_ang =安培; f_su_submit2 =俗尘&安培; f_sp_karte =上

这是从搜索查询生成的,搜索查询可以包含多个参数,参数数量也不固定。

我是如何使用.htaccess创建的,以便variable=value代替/value {{1}} e.g。

  

www.domain.com/index.php?id=42&f_su_ort=Berlin

应转换为

  

www.domain.com/42/Berlin

我只能编辑.htaccess文件,而不是脚本。

感谢。

1 个答案:

答案 0 :(得分:0)

RewriteRule ^([^/]*)/([^/]*)/([^/]*).....$ http://www.domain.com/index.php?id=$1&f_su_ort=$2..... [L,QSA]