Kew Kylyu Vacquier Kew Kylyu Vacquier - 8 months ago 38
Apache Configuration Question

Apacha configure RedirectMatch arguments, add one to others

i nedd to transform an url like this :
/fr-ca/home.html?titi=toto to /fr/home.html?titi=toto&country=ca
And of course /fr-ca/home.htm /fr/home.html?country=ca

but it's always redirtect to home, removing the page.

where am i wrong ?

RedirectMatch 301 "^/([a-z]{2})-([a-z]{2})/(.*?)" "/$1/$3?country=$2"
RedirectMatch 301 "^/([a-z]{2})-([a-z]{2})/(.*)" "/$1/$3&country=$2"


RedirectMatch directive won't help here because you want new query parameter to be added in previous query string. This feature is only available using QSA flag in mod_rewrite module.

You can use:

RewriteEngine On

RewriteRule ^([a-z]{2})-([a-z]{2})/(.*)$ /$1/$3?country=$2 [L,QSA,NC,R=301]

QSA (Query String Append) flag preserves existing query parameters while adding a new one.

Make sure to clear your browser cache before testing.