重写使用Apache的mod_rewrite多个变量规则 [英] Rewrite rule on multiple variables using Apache mod_rewrite

查看:118
本文介绍了重写使用Apache的mod_rewrite多个变量规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我怎么可以重写 www.site.com?lang=lv&type=1&mode=2 WWW .site.com / LV / 1/2 使用Apache mod_rewrite的选项。

I would like to know how can I rewrite www.site.com?lang=lv&type=1&mode=2 into www.site.com/lv/1/2 using Apache mod_rewrite options.

推荐答案

您需要单独处理URI路径和查询。如果参数出现在非常相同的顺序,你可以这样做:

You need to handle the URI path and query separately. If the parameters appear in that very same order, you can do this:

RewriteCond %{QUERY_STRING} ^lang=([^&]+)&type=([^&]+)&mode=([^&]+)$
RewriteRule ^$ /%1/%2/%3? [L,R=301]

否则,你将需要把他们以正确的顺序使用这个规则之前,或采取每个参数在一个时间。

Otherwise you will need to put them in the right order before using this rule or take each parameter at a time.

这篇关于重写使用Apache的mod_rewrite多个变量规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆