Regex with RewriteRule
Posted: Sat Dec 16, 2006 5:12 pm
In my .htaccess file I use a RewriteRule as follows:
This says to match a url like this:
and redirect it to:
The problem that I'm having is that if at the end of the URL there's a /, it becomes part of the ID, like this:
instead of having ...id=anID, I'm getting id=anID/
In my regex the / isn't inside the parentheses so I don't understand why it's being saved as part of backreference $2.
Any ideas?
Code: Select all
RewriteRule ^([^images][A-Za-z]*)/(.*)/? index.php?section=$1&id=$2Code: Select all
www.site.com/aSection/anIDCode: Select all
index.php?section=aSection&id=anIDCode: Select all
URL is www.site.com/aSection/anID/In my regex the / isn't inside the parentheses so I don't understand why it's being saved as part of backreference $2.
Any ideas?