views:

75

answers:

2

When I run newly created Rails application on Apache, I can only access it's default front page ( standard app/public/index.html) file. When I try to run custom method via URI I get page not found. So I'm guessing that something is wrong with my .htaccess. Do I have to "open" it for every controller?

RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^main(.*) "http\:\/\/127\.0\.0\.1\:12005\/$1" [P,L]

Edit: I'm adding mongrel log

Error calling Dispatcher.dispatch #<NoMethodError: private method `split' called for nil:NilClass>
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/cgi_process.rb:52:in `dispatch_cgi'
A: 

Heh, Ruby on Rails does not care about .htaccess. Welcome to the MVC world :-) Most likely, you didn't define any routes inside rails. Or you're not using passenger.

Tass
MVC has nothing to do with routing.
Gumbo
I can't install passenger gem on my hosting server.
dd
Mongrel + apache? Interessting setup... Can't you use passenger or unicorn (with nginx)? Would make things easier...
Tass
can't install passenger or unicorn gem
dd
A: 

First of all, you can change the first two rules to:

RewriteCond %{HTTP_HOST} ^(www\.)?example.com$

Also, the last rule doesn't need all those backslashes, and since there's a slash before your $1 you should have one in ^main(.*) too:

RewriteRule ^main/(.*)$ "http://127.0.0.1:12005/$1" [P,L]

Try if that works. i'm not sure what P does and how that works, so if the problem is in there I can't help you..

Litso
On replace either of the lines nothing happens. Not even index.html is showing. Deploying Rails is really painful.
dd
Sorry, I have no knowledge of Rails. I'd think htaccess has nothing to do with whichever framework you use, but if I'm wrong there's not much I can do. What happens if you change `[P,L]` to `[L]`?
Litso
I really don't know. This code is something Cpanel generate as a RewriteRule.
dd
what if you remove it entirely?
Litso
Then I can't access it at all.
dd