Q:

.htaccess redirect normal url to query string

I have a url of the form:
www.example.com/r/abc/1234

that I want to rewrite to:
www.example.com/r.php?deb=abc&id=1234

And another url:
www.example.com/r/12bcd-qsqs-343-wdwd/1234

which should be rewritten to:
www.example.com/r.php?abc_id=12bcd-qsqs-343-wdwd&id=1234

Both of these rule should be handled by .htaccess. Any suggestions?

A:

Both the URIs that you want to redirect look similar except that 2nd one has hyphens - in first query parameter.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^r/([^-]+)/(.+)/?$ r.php?deb=$1&id=$2 [L,QSA]

RewriteRule ^r/([a-z0-9-]+)/(.+)/?$ r.php?abc_id=$1&id=$2 [L,QSA,NC]

