Arun Chandran
Arun Chandran

Reputation: 330

htaccess remove query string and then redirect

I need to redirect a url based on query string and need to remove the query string on redirect.

Source url: http://www.example.com/?id=15&L=1&link=androidapp

Target url: http://www.example.com/test.php&id=15&L=1

'?id=' is a dynamic parameter. It is changed everytime.

I wrote following condition. It redirects, but I didn't get the desired target url.

RewriteCond %{QUERY_STRING} link=androidapp 
RewriteRule ^(.*)$ http://www.example.com/test.php? [R=301,L]

Please help me.

Upvotes: 0

Views: 471

Answers (1)

Croises
Croises

Reputation: 18671

You can use this .htaccess:

RewriteCond %{QUERY_STRING} id=(\d+)&L=(\d+)&link=androidapp [NC]
RewriteRule ^ test.php?id=%1&L=%2 [R=301,L]

Upvotes: 1

Related Questions