.htaccess规则重写特定的查询参数并将其余部分保留在URL中

时间:2018-06-14 20:27:06

标签: .htaccess

我无法确定如何在我的.htaccess规则中执行以下设置。我的目标是获取 lang = es 参数并将其转换为URL中的/ es,同时保留结果URL中的所有其他参数。

原始网址的示例方案

https://example.com/?lang=es | Includes question mark 
https://example.com?lang=es | Excludes question mark
https://example.com/?lang=es&param1=apple | Includes an additional parameter
https://example.com/?lang=es&param1=apple&param2=banana | Includes unlimited additional parameters
https://example.com/?param1=apple&lang=es | Lang parameter not the first one in the URL

每种方案的所需输出

https://example.com/es
https://example.com/es
https://example.com/es/?param1=apple | Note this strips the "&" that was preceding param1 in the original URL
https://example.com/es/?param1=apple&param2=banana
https://example.com/es/?param1=apple

在撰写这些规则时,我是一位相对新手,所以我们非常感谢所有的帮助!

0 个答案:

没有答案
相关问题