Reputation: 49
I have problem and dont have any idea how to solve it. I have URL like this: http://somedomain.com/link.php?lnk=1&sid=dsds
and need to change it to this:
http://somedomain.com/link/1/dsds
If there is only one variable I use this:
RewriteEngine on
RewriteRule ^link/([a-zA-Z0-9_-]+)$ link.php?lnk=$1
But I don't have any idea how to attach that second variable &sid={something}
Thanks in advance for any help.
Upvotes: 1
Views: 98
Reputation: 342
Try this:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^lnk=(.+)\&sid=(.+)
RewriteRule ^link\.php link/%1/%2/? [R=301,L]
Upvotes: 0
Reputation: 1642
if the first parameter/value uses digits only, then you can use
RewriteEngine On
RewriteRule ^link/([0-9]+)/([a-zA-Z0-9_-]+)$ link.php?lnk=$1&sid=$2 [L]
Apache mod_rewrite Introduction (see "Figure 1" in "Regex Back-Reference Availability" section)
Upvotes: 1
Reputation: 41448
RewriteEngine on
RewriteRule ^link/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ link.php?lnk=$1&sid=$2
Upvotes: 3