Redirection 301 with htaccess with url variables

2019-08-31 02:10发布

问题:

I've searched answers on the forum but didn't worked for me.

I have rebuild an website using Wordpress and want to keep old urls.

I have old URLs like : index.php?option=com_content&view=article&id=51&Itemid=67&lang=fr

that i want to move permanantly to url like : /produits-et-services/conseil-et-accompagnement/

Redirect 301 didn't worked because of vars in URL.. and i've try this :

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=51&Itemid=67&lang=fr$ [NC]
RewriteRule ^index.php$ http://solunea.fr/produits-et-services/conseil-et-accompagnement/ [L,R=301]

On my wordpress .htaccess but didn't worked either.

Can someone help me please ??

回答1:

Make sure this rule:

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=51&Itemid=67&lang=fr$ [NC] 
RewriteRule ^(index\.php)?$ /produits-et-services/conseil-et-accompagnement/ [L,R=301,NC]

is placed right on top before any other existing rewrite rule

and test in a different browser to avoid 301 caching issues.