I want to redirect my dynamic links to new parameter.
My Old code for Files:
https://www.example.com/index.php?a=browse&b=category&id=[DYNAMIC ID IN NUMBERS]
I want new for Files :
https://www.example.com/index.php?a=downloads&b=file&id=[DYNAMIC ID IN NUMBERS]
How to do that in .htaccess?
My current .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
</IfModule>
To redirect the "old" URL to the "new" whilst maintaining the "old" dynamic id, try the following before your existing directives:
RewriteCond %{QUERY_STRING} ^a=browse&b=category&id=(\d+)
RewriteRule ^(index\.php)$ https://www.example.com/$1?a=downloads&b=file&id=%1 [R=301,L]
The $1 backreference simply matches index.php and saves repetition.
The %1 (as opposed to $1) is a backreference to the captured pattern in the preceding CondPattern ie. the value of the id URL parameter.