Ruby on Rails .htaccess 问题
当我在 Apache 上运行新创建的 Rails 应用程序时,我只能访问它的默认首页(标准 app/public/index.html)文件。当我尝试通过 URI 运行自定义方法时,我发现页面未找到。所以我猜测我的 .htaccess 有问题。我必须为每个控制器“打开”它吗?
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^main(.*) "http\:\/\/127\.0\.0\.1\:12005\/$1" [P,L]
编辑: 我正在添加杂种日志
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'
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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题实际上是在 Rails 2.3.x 和 Mongrel 之间,而不是 .htaccess 之间
进行了讨论&在 https://rails 找到了解决方案(通过猴子修补) .lighthouseapp.com/projects/8994/tickets/4690#ticket-4690-43
The problem is actually between Rails 2.3.x and Mongrel, instead of .htaccess
It was discussed & a solution was found (by monkey patching) at https://rails.lighthouseapp.com/projects/8994/tickets/4690#ticket-4690-43
呵呵,Ruby on Rails 不关心 .htaccess。欢迎来到 MVC 世界 :-) 最有可能的是,您没有在 Rails 内定义任何路线。或者你没有使用乘客。
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.
首先,您可以将前两个规则更改为:
另外,最后一个规则不需要所有这些反斜杠,并且由于 $1 之前有一个斜杠,因此您在 ^main(.*) 中也应该有一个斜杠:
尝试一下作品。我不确定 P 做了什么以及它是如何工作的,所以如果问题在那里我无法帮助你..
First of all, you can change the first two rules to:
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:
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..