title: How to .htaccess 301 redirect only if the final URL segment is empty
body: <p>I'm using ExpressionEngine and it is generating a URL like this when viewing a specific category:</p>
  
  <p>domain.com/index.php/template_group/template/category_URL_indicator/foo_category/</p>
  
  <p>I would like to redirect visitors if they delete the specific category from the final segment of the URL. For example, if they made the URL this:</p>
  
  <p>domain.com/index.php/template_group/template/category_URL_indicator/</p>
  
  <p>I tried an .htaccess 301 redirect but redirecting the shorter URL also redirected the longer URL. That is, if I put this in .htaccess:</p>
  
  <pre><code>redirect 301 http://www.domain.com/index.php/template_group/template/category_URL_indicator http://www.domain.com
  </code></pre>
  
  <p>This also redirected the longer URL to become <a href="http://www.domain.com/foo_category/" rel="nofollow">http://www.domain.com/foo_category/</a> - not what was required... Any suggestions welcome - thanks!</p>
  
  <p>David.</p>