Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

If I write in my browser or all the pages work as expected. But if I write or 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} ^$ [OR]
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^/?$ "http\:\/\/127\.0\.0\.1\:12007%{REQUEST_URI}" [P,QSA,L]

which I guess was generated by CPanel Rewrites.

share|improve this question
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?


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 ^(.*)$$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


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.