I have come up with the following mod_rewrite rule: RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ $1/ [R=301,L]
It serves an HTTP/1.1 301 Moved Permanently header, in the case that there is no trailing slash in the {REQUEST_URI} and the {REQUEST_URI} does not have a file extension. This seems to work well. Does anyone else use this technique? Jonathan On Fri, Aug 28, 2009 at 5:56 AM, Jonathan Maron<jonathan.a.ma...@gmail.com> wrote: > Hello all > > Would anyone know of a technique, ideally at the Apache level, that > redirects requests to a module, controller or action, without a > trailing slash to the same module, controller or action with a > trailing slash. > > For example: > > http://www.example/contact/sales > > is a valid request and displays the page. > > However, the desired behavior is to redirect to: > > http://www.example/contact/sales/ > > (note trailing slash). > > The "standard" Apache solution to this problem is described at > http://is.gd/2D91v > > RewriteEngine on > RewriteBase /~quux/ > RewriteCond %{REQUEST_FILENAME} -d > RewriteRule ^(.+[^/])$ $1/ [R] > > However, this approach can not be used with a ZF application, as > {REQUEST_FILENAME} is 'index.php'; '-d' cannot be used as > '/contact/sales' is not an actual directory. > > TIA > > Jonathan Maron >