I have the following rewrite set up:
RewriteRule r/(.*) scripts/report.php?cp=1&id=$1
It works great to redirect mydomain.com/r/123abc but it's redirecting all pages on the server that begin with an "r". Does anyone know how I can make this more specific to only redirect when the url is mydomain.com/r/ ? I should note that I need to keep this generic so I can't include mydomain.com in the rule.
Try putting a ^/
in front of your r/(.*)
rewrite rule. This would make it:
RewriteRule ^/r/(.*) scripts/report.php?cp=1&id=$1
I'm not sure if this works for you (not tested), but try it out:
# Rewrite ini
RewriteEngine on
RewriteBase /mydomain.com/
# Redirect all /mydomain.com/r/* calls to scripts/report.php
RewriteRule ^r/(.*)$ scripts/report.php?cp=1&id=$1 [QSA]
Hope that helps.
You should specify that the RegEx should match the entire string rather than just match the string. You can do this using the ^
and $
symbols:
RewriteRule ^r/(.*)$ scripts/report.php?cp=1&id=$1