title: Use htaccess and mod_rewrite to conditionally make url segment uppercase
body: <p>I am trying to rewrite my URL's to do the following:</p>
  
  <p>If the last segment of the URL starts with a 'p' followed by a number, that P should be uppercase.</p>
  
  <p>So: <code>domain.com/path/to/something/p112</code> should become <code>domain.com/path/to/something/P112</code>, but <code>domain.com/p123/something/else</code> should NOT become <code>domain.com/P123/something/else</code></p>
  
  <p>I know how to simply replace characters, but I'm not sure how to limit this to the last segment, and only apply if it matches a certain pattern:</p>
  
  <pre><code>RewriteRule ^(.*)p(.*)$ /$1P$2 [L,R=301]
  </code></pre>