Rails rewrites URL by appending "dispatch.cgi" to URL

hi-

i have a rails running on a server, but when i access my site as:

http://test.com

it rewrites the URL with the name of the dispatch.cgi script:

http://test.comdispatch.cgi%2Flist_topics”

which then fails to resolve.

i’m using the standard .htaccess file and dispatch.cgi file.

any ideas?

thanks,
augusto.

.htaccess

Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
ErrorDocument 500 “

Application error

Rails application failed to
start properly”

dispatch.cgi

#!/usr/bin/ruby
require File.dirname(FILE) + “/…/config/environment” unless
defined?(RAILS_ROOT)
require “dispatcher”
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

routes.rb

ActionController::Routing::Routes.draw do |map|
map.connect ‘:action/:id’,
:controller=>‘board’
end

board_controller.rb

class BoardController < ApplicationController
def index
redirect_to :action=>‘list_topics’
end

Augusto,

Can you try the below .htaccess and see if that helps.

CGI

AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On

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

ErrorDocument 500 “

Application error

Rails application failed to
start properly”

FCGI

AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI
RewriteEngine On

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

ErrorDocument 500 “

Application error

Rails application failed to
start properly”

Thanks,
Kilari.
http://kilari.co.in

Augusto Callejas wrote:

hi-

i have a rails running on a server, but when i access my site as:

http://test.com

it rewrites the URL with the name of the dispatch.cgi script:

http://test.comdispatch.cgi%2Flist_topics”

which then fails to resolve.

i’m using the standard .htaccess file and dispatch.cgi file.

any ideas?

thanks,
augusto.

.htaccess

Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
ErrorDocument 500 “

Application error

Rails application failed to
start properly”

dispatch.cgi

#!/usr/bin/ruby
require File.dirname(FILE) + “/…/config/environment” unless
defined?(RAILS_ROOT)
require “dispatcher”
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if
File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch

routes.rb

ActionController::Routing::Routes.draw do |map|
map.connect ‘:action/:id’,
:controller=>‘board’
end

board_controller.rb

class BoardController < ApplicationController
def index
redirect_to :action=>‘list_topics’
end