samedi 5 septembre 2020

How to remove get parameter from url with .htaccess?

My .htaccess file changes (for example) "domain.lc/brands/beams/..." to "domain.lc/php/mvc.php?htTargUrl=brands/beams/..." with QSA rule. There's the rule:

RewriteRule ^(.+)$ php/mvc.php?htTargUrl=$1 [QSA,L,B,BNP,NC]

And i need to remove htTargUrl parameter from original url. For example: "domain.lc/brands/beams/?htTargUrl=beams&par2=val" to "domain.lc/brands/beams/?par2=val"

I tried many rules to do this, but no one worked pertty good with query string. If i use

RewriteCond %{QUERY_STRING} ^(.*)&?htTargUrl=[^&]+&?(.*)$ [NC]
RewriteRule ^/?(.*)$ /$1?%1%2 [R=301,L]

then parameter removes not only from the original link and urls becomes "domain.lc/php/mvc.php" How can i get it?




Aucun commentaire:

Enregistrer un commentaire