Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Ruby on Rails application that works ok on my notebook ( http://localhost:3000/ )

If I write in my browser http://example.com:12007/ or http://www.example.com:12007/ all the pages work as expected. But if I write http://example.com/ or http://www.example.com/ the first page is displayed, but without any css or images (just like it wouldn't find them). I can see all the text (even the text from my MySQL database), but with no format. And if I click on any link, I get a error page like this:

Not Found

The requested URL /some_controller was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

What should I do to make my website work without writing the port in the address bar?


The content of my /public_html/.htaccess file is

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

which I guess was generated by CPanel Rewrites.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Can you access the /some_controller resource directly if you point your browser to it? The same holds true for your CSS files. Can you post a snippet of the HTML source that includes a the HREF's or the SRC's for your links/CSS?

Edit...

Now that I look at that rewrite rule, of course it doesn't work.

^/?$

That's only going to match a URL at /. Change it to:

RewriteRule ^(.*)$ http://127.0.0.1:12007/$1 [P,QSA,L]

And it should tick. Note that the above will proxy all requests to Rails. You should probably host your media outside of Rails' control, but that's an exercise for the reader.

share|improve this answer
    
It really works! Thanks a lot! I didn't understand exactly what you said about my media. At the moment, all my files and images and everything are located in /rails_apps/my_project/. And in /public_html I have only .htaccess. What is the best-practice? –  True Soft Mar 16 '10 at 21:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.