What would I make this rule so that you can access it with and without trailing slash?
RewriteRule ^members/([^/]+)$ members.php?id=$1 [L]
What would I make this rule so that you can access it with and without trailing slash?
RewriteRule ^members/([^/]+)$ members.php?id=$1 [L]
I don't know anything about this "mod-rewrite
" you speak of (probably an Apache module?), but that sure looks like a regex, and I know about those. :-)
Try this:
RewriteRule ^members/([^/]+)(/|)$ members.php?id=$1 [L]
So, to break that into pieces, the ^
means "begins with", "members/
" means matching exactly that, ([^/]+)
means "1 or more characters that aren't slash, assigning to $1
", (/|)
means "slash or empty string, assigning to $2
", and the $
part at the end means "the string has to end here".
RewriteRule ^members/([^/]+)/?$ members.php?id=$1 [L]
Just added "/?" at the end to say look for a trailing slash but the ? says it doesn't have to be there.