Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mod Rewrite, pass parameters from URL1 to URL2

I'm trying to rewrite the following URL

test.php?par1=foo&par2=bar

Into...

newtest.php?hidden_par=blah&par1=foo&par2=bar

I have this rule, that does not work:

RewriteRule ^test.php\??(.*?)$ newtest.php?hiden_par=blah&$1 [L]

Could this be done using RewriteCond or something else? (say, could this be done ?), thanks in advance.

like image 745
grilix Avatar asked Jan 26 '26 21:01

grilix


1 Answers

You probably want something like the QSA ("query string append") flag, which causes the remainder of the query string to be properly appended onto the end of the rewritten URL.

For example:

^test.php test.php?hidden=value [L,QSA]
like image 91
Rob Avatar answered Jan 29 '26 14:01

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!