views:

64

answers:

2

Hello!

I have a big problem (even my server's admin seems to have some difficulties to solve it).

I used my cpanel (11.25.0-STABLE) to create a new ruby on rails application, which work fine when accessed to its original uri (with port number).

To make that uri more "user friendly", I have created a rewrite to access my RoR application without showing the port number.

Content of my .htaccess for my rewritten uri

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^greendeers.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.greendeers.com$
RewriteRule ^.*$ "http\:\/\/127\.0\.0\.1\:12001%{REQUEST_URI}" [P,QSA,L]

app/controllers/helloworld_controller.rb

class HelloworldController < ApplicationController
  def index
  end
end

app/views/layouts/helloworld.html.erb

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title><%= controller.controller_name %>: <%= controller.action_name %></title>
  <%= stylesheet_link_tag 'scaffold' %>
</head>
<body>

  <p style="color: green"><%= notice %></p>

  <%= yield %>

</body>
</html>

app/views/helloworld/index.html.erb

<h1>HELLO WORLD</h1>

The first page (original one created by RoR) works fine with both uri, but when accessing one of my controller, the html is not rendered, instead, the html code is displayed.

http://www.greendeers.com/helloworld

This page renders as expected using the original uri (same as above, with port number :12001)

My log display the same thing when accessing both uri:

Processing HelloworldController#index (for [My ip address] at 2010-07-10 02:53:20) [GET]

Rendering template within layouts/helloworld

Rendering helloworld/index

Completed in 1ms (View: 1, DB: 0) | 200 OK [http://greendeers.com/helloworld]

Do you have a clue on how to fix it?

Sorry, I can only post one link per post at the moment :/

A: 

It's because you use badly your .htaccess.

Use a proxy system or passenger instead . Not your rewrite rules

shingara
Thanks for your reply.Can you tell me more about passenger? I just started using RoR, I don't know much about it.
samuel.molinari
read the documentation : http://www.modrails.com/
shingara
Any other solutions apart those 2? My web hosting provider won't allow me to install Passenger... I start wondering if it was the right decision to go with them. Otherwise I will have to move my website somewhere else.
samuel.molinari
A: 

I fixed it. It was something to do with mongrel. I found the solution here:

https://rails.lighthouseapp.com/projects/8994/tickets/4690

:)

samuel.molinari