Htaccess永久重定向

时间:2015-04-08 15:26:00

标签: apache .htaccess mod-rewrite redirect query-string

我尝试执行以下单一重定向:

http://www.mapfre.com.gt/index.php?option=com_content&view=article&id=37%3Acontactenos-ventas&catid=3%3Aproductos&Itemid=15

301重定向到:

https://www.mapfre.com.gt/seguros-gt/sobre-mapfre-guatemala/contacto/

我一直在研究这个并试过以下内容:

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=37%3Acontactenos-ventas&catid=3%3Aproductos&Itemid=15$

RewriteRule ^index\.php$ https://www.mapfre.com.gt/seguros-gt/sobre-mapfre-guatemala/contacto/ [R=301,L]

但结果是:

https://www.mapfre.com.gt/seguros-gt/sobre-mapfre-guatemala/contacto/?option=com_content&view=article&id=37%253Acontactenos-ventas&catid=3%253Aproductos&Itemid=15

任何建议都将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

您只需要在重写中添加?以截断查询字符串:

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=37%3Acontactenos-ventas&catid=3%3Aproductos&Itemid=15$
RewriteRule ^index\.php$ https://www.mapfre.com.gt/seguros-gt/sobre-mapfre-guatemala/contacto/? [R=301,L]