How do I write a rewrite rule so that it takes in part of URL and redirects the user to a file with that part of the URL as a query string.
Specifically, I’d like to redirect a user from the following:
http://localhost/SR/XXYYYZZ
to the following:
http://localhost/sr.php?sr=XXYYZZ
Here’s how I’ve written the rule:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/SR/(.*)$
RewriteRule ^SR/(.*)$ sr.php?sr=$1 [L]
This clearly doesn’t work. My apologies if this is blatantly obvious. I’m really a beginner when it comes to Apache and regular expressions.
You’re on the right track. Try this: