I have updated my website. Previously there were links like these: http://example.com/bla-bla-bla?language=de . After update, these links should be 301-redirected to http://de.example.com/bla-bla-bla
I tried this, but it did not work:
RewriteRule ^(.*)language=(fr|de|it|es|pt) http://$2.example.com/$1 [R=301,NC]
Thanks for help.
Get parameters can not be extracted with the RewriteRule command. They are contained in the %{QUERY_STRING} variable. You can extract a specific value using RewriteCond. Then with the ‘%’ prefix
Example
We added the L flag to stop rewrite rules.
It is good practice to set a default value in case someone access the old page without the language parameter.
I used fr because i’m french =)
Regards