I need to include an optional trailing forwardslash, that\'s an /, in my RewriteRule
What I have so far is
RewriteRule ^([a-zA-Z0-9]+)$ u.php?$1|$2
<
Just put /?
before the $
at the end in your pattern:
RewriteRule ^([a-zA-Z0-9]+)/?$ u.php?$1
But I would rather suggest you to allow just one spelling (either with or without trailing slash) and redirect the other one:
# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ /$1 [L,R=301]
# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ /$0/ [L,R=301]