Rails and a trailing slash

software development

#1

Can someone give me a pointer on why I am seeing 301 redirects in the access logs for my Rails application. This is what it looks like.

    • [16/Dec/2007:19:15:11 -0800] “GET /shops HTTP/1.1” 301 591 “http://www.stagingtracks.com/” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11”
    • [16/Dec/2007:19:15:11 -0800] “GET /shops/ HTTP/1.1” 200 89174 “http://www.stagingtracks.com/” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11”

It is really causing problems with the Rails way of using RESTful actions. When I try to POST to /shops, I end up getting a 301 redirect to /shops/ using GET. This means that NONE OF MY DATA IS GETTING SUBMITTED :slight_smile:

    • [16/Dec/2007:19:24:30 -0800] “POST /shops HTTP/1.1” 301 591 “http://www.stagingtracks.com/shops/new” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11”
    • [16/Dec/2007:19:24:30 -0800] “GET /shops/ HTTP/1.1” 200 319 “http://www.stagingtracks.com/shops/new” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11”

The strange thing is that this doesn’t seem to be happening on all of my paths. The ones that this happens on are: /posts, /shops, /shows, /clubs. It does not happen on /search. I am perplexed, to say the least.

This is what the .htaccess looks like:

RewriteEngine On

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

Thoughts? Advice?

Thanks


#2

DirectorySlash Off

in the .htacess file fixes it.