I am trying to match a single reference in a URL to pass to a script, while retaining the rest as the path to the script. For example:
#/scripts/paramater/foo/bar.php should call
#/scripts/foo/bar.php?id=parameter
RewriteRule ^scripts/([^/]+)/(.*)$ scripts/$2?id=$1 [L,QSA]
However my backreference is matching multiple times. $2 only contains "bar.php" and $1 is somehow repeating for "parameter" and "foo".
How can I prevent the backreference from repeating itself?
Edit: I've narrowed down the problem somewhat by fiddling with the second part of the rewrite rule.
#This doesn't work, as above
#Outputs: scripts/bar.php?id=foo?id=parameter
RewriteRule ^scripts/([^/]+)/(.*)$ scripts/$2?id=$1 [L,QSA]
#This works
#Outputs: foo/bar.php?id=parameter
RewriteRule ^scripts/([^/]+)/(.*)$ $2?project_slug=$1 [L,QSA]
Which confuses me even more! Any help appreciated