.htaccess HTaccess删除URL开头的查询字符串

.htaccess HTaccess删除URL开头的查询字符串,.htaccess,mod-rewrite,rewrite,.htaccess,Mod Rewrite,Rewrite,我使用的翻译系统目前不适用于非友好URL,例如 /index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1_Height_comp=find_in_set_any&product_type_1_Height[0]=Short+%28up+to+80cm%29&product_type_1_Strain_comp

我使用的翻译系统目前不适用于非友好URL,例如

/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1_Height_comp=find_in_set_any&product_type_1_Height[0]=Short+%28up+to+80cm%29&product_type_1_Strain_comp=find_in_set_any&product_type_1_Strain[0]=Asia-Central&product_type_1_Yield_comp=find_in_set_any&product_type_1_Yield[0]=High
所以我补充说:

RedirectMatch 301 /es/(.*)index.php(.*)$ http://www.seed-city.com/$1
。。。进入my.htaccess文件以重定向到英文版本。但是,在重定向到英文版本后,它在url前面添加了
?lang=es&url=
,我希望能够删除它。它也可以是
?lang=fr&url=
?lang=de&url=
?lang=zh-CN&url=

我已经尽我所能地尝试了,但是我没能成功地移除它。感谢您的时间和任何帮助将不胜感激。谢谢,Natastna2

编辑:

@谢谢你的回复。我想使用以下url:

http://www.seed-city.com/?lang=es&url=index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1_seed_type_comp=find_in_set_any&product_type_1_seed_type[0]=Regular&product_type_1_indoor_flowering_time_comp=find_in_set_any&product_type_1_indoor_flowering_time[0]=Medium+%2856+to+90+days%29&product_type_1_Outdoor_harvest_time_comp=find_in_set_any&product_type_1_Outdoor_harvest_time[0]=Middle+of+September
并将其更改为:

http://www.seed-city.com/index.php&option=com_virtuemart&page=shop.browse&category_id=&product_type_id=1&product_type_1_seed_type_comp=find_in_set_any&product_type_1_seed_type[0]=Regular&product_type_1_indoor_flowering_time_comp=find_in_set_any&product_type_1_indoor_flowering_time[0]=Medium+%2856+to+90+days%29&product_type_1_Outdoor_harvest_time_comp=find_in_set_any&product_type_1_Outdoor_harvest_time[0]=Middle+of+September
从开头删除
?lang=es&url=
。这是因为现在,如果有人单击西班牙语翻译按钮一次,它会重定向到英语版本,因为它符合我以前的规则:

RedirectMatch 301 /es/(.*)index.php(.*)$ http://www.seed-city.com/$1

但是,如果他们单击一次,URL现在以?lang=es&URL=开头,因此与我以前的规则不匹配。在他们第二次点击翻译标志时,他们会被带到错误页面,而不是我更喜欢的英文版本。这就是我试图从URL前面删除查询的原因。结果URL应该没有语言标识符,因为它是英语默认语言。感谢您的回复。

如果您想隐藏lang=foo并模拟类似于
/foo/index.php
的目录,您可以使用以下规则:

RewriteRule ^([a-z-]+)/index.php index.php?lang=$1 [QSA,L]

请注意,我假设您在.htaccess文件中使用此规则。在apache配置中,URL将以
/
开头,因此您必须将其添加到
^
字符之后。

仍然不清楚您有什么标准,您到底想要实现什么?请举例说明用户应该在浏览器中看到什么URL,以及它应该被传输到什么真实的URL。-如果可能,请使用格式。@v我已经编辑了我的文章。谢谢。@user689061您的第一个URL没有开头,它只是查询字符串中的一个字符串。@vbence很抱歉,它不允许我再发布任何超链接。如果你能加上h-ttp://www.seed-city.com/ 首先,这是正确的URL。@user689061我认为这不可能像您的示例所建议的那样,因为第二个URL没有任何提示语言的内容。es完全消失,因此无法从第二个重新创建第一个。嗨,我不想模拟目录。我只想从url的开头删除以下内容:?lang=es&url=。我试着使用:RewriteRule^/index.php index.php?lang=$1[QSA,L],但没有成功。再次感谢你,蚂蚁。