I have a link like this: http://mysite.com/r/user/ and/or http://mysite.com//blah/r/user/ I need this to redirect to http://mysite.com/?r=user and/or http://mysite.com/blah/?r=user The blah part is a potential subfolder on my site. I can't find the right way to do this kind of redirect.. I tried with htaccess and php but without success. Any help would be appreciated. Thanks.
Try this: RewriteEngine On RewriteRule ^r/([a-z]+)/([a-z]+)/$ /\$1/?r=$2[L] RewriteRule ^r/([a-z]+)/$ /\?r=$1[L] Code (markup): The first one matched the URL with folder name. And the second one matches those without folder name. I haven't tested it. But I think it would work.