This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here

Skip to main content

Just Host Web Hosting Help

Ruby on Rails 404 Errors

Problem:

My Ruby on Rails installation keeps displaying a '404 Not Found' error.

Solution:

Please create a .htaccess file inside the public folder with the following code:
# General Apache options
            AddHandler fcgid-script .fcgi
            AddHandler cgi-script .cgi
            Options +SymLinksIfOwnerMatch +ExecCGI
            
            # If you don't want Rails to look in certain directories,
            # use the following rewrite rules so that Apache won't rewrite certain requests
            # 
            # Example:
            #   RewriteCond %{REQUEST_URI} ^/notrails.*
            #   RewriteRule .* - [L]
            
            # Redirect all requests not available on the filesystem to Rails
            # By default the cgi dispatcher is used which is very slow
            # 
            # For better performance replace the dispatcher with the fastcgi one
            #
            # Example:
            #   RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
            RewriteEngine On
            
            # If your Rails application is accessed via an Alias directive,
            # then you MUST also set the RewriteBase in this htaccess file.
            #
            # Example:
            #   Alias /myrailsapp /path/to/myrailsapp/public
            #   RewriteBase /myrailsapp
            
            RewriteBase /
            RewriteRule ^$ index.html [QSA]
            RewriteRule ^([^.]+)$ $1.html [QSA]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
            
            # In case Rails experiences terminal errors
            # Instead of displaying this message you can supply a file here which will be rendered instead
            # 
            # Example:
            #   ErrorDocument 500 /500.html
            
            ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
This should fix the 404 error.
Knowledgebase Article 231,356 views bookmark tags: file missing public rails ruby


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

When I attempt to execute my Ruby on Rails application I receive &quot;500- Premature end of script.&quot;
Knowledgebase Article 169,138 views tags: premature rails ruby script

What Ruby on Rails version and Gems are installed?
Knowledgebase Article 165,548 views tags: gem gems rails ruby

How do I setup Ruby on Rails?
Knowledgebase Article 403,262 views tags: rails ruby

Related Help Content

How to install Redmine a Ruby on Rails application
Knowledgebase Article 129,363 views tags: redmine ruby

How do I install my own Ruby Gems?
Knowledgebase Article 195,153 views tags: gem install ruby

Error Log receiving this error: PHP Warning: Zend Optimizer for PHP 4.4.x cannot be found (expected at '/usr/local/Zend/lib/Optimizer-2.5.10/php-4.4.x/ZendOptimizer.so') - try reinstalling the Zend Op
Knowledgebase Article 156,031 views tags: found optimizer zend

How do I create a Public/Private Key Pair in cPanel for use via SSH?
Knowledgebase Article 618,592 views tags: key private public putty ssh windows

Rails Troubleshooting!
Knowledgebase Article 107,521 views tags: rails

This article will show a few MySQL errors along with explanations as to why they might be occurring.
Knowledgebase Article 131,835 views tags: errors mysql

This article will explain some common causes for 500 errors on Dedicated or V.P.S servers.
Knowledgebase Article 129,829 views tags: dedi dedicated error server vps

When logging into phpMyAdmin, why do I get a 404 not found error?
Knowledgebase Article 194,492 views tags: database found phpmyadmin select

** Google ad credits are only available to customers in the United States, Canada, and the United Kingdom at this time.

¹ VAT (Value Added Tax) is not included in our advertised price and will be charged separately and itemized on invoices and billing information. Standard VAT rates based on EU Member State regulations may apply. Learn more.