title: .htaccess regular expression need to make trailing forward slash optional
body: <p>I need to include an optional trailing forwardslash, that's an /, in my RewriteRule</p>
  
  <p>What I have so far is</p>
  
  <pre><code>RewriteRule ^([a-zA-Z0-9]+)$ u.php?$1|$2
  </code></pre>
  
  <p>Which works fine, for example <a href="http://foo.bar/abcde" rel="noreferrer">http://foo.bar/abcde</a> will redirect to <a href="http://foo.bar/u.php?abcde" rel="noreferrer">http://foo.bar/u.php?abcde</a> and handles any querystring parameters that may be present.</p>
  
  <p>What I need to do is take <a href="http://foo.bar/abcde/" rel="noreferrer">http://foo.bar/abcde/</a> (with the trailing forwardslash) and redirect to <a href="http://foo.bar/u.php?abcde" rel="noreferrer">http://foo.bar/u.php?abcde</a></p>
  
  <p>So, if its present, I need remove the final forward slash from $1 in my RewriteRule. How do I do this? I'm new to apache and have tried many different regex rules but can't get it right.</p>