Run rails app under subfolder

2019-02-26 07:30发布

问题:

I've been testing my rails app on localhost:3000 and it works just fine. However, when deploying to my host, the root URL is:

http://99.88.77.66/~username

I do not have a domain name at this point.

When I point the browser to the above URL I get the root not found for:

/~username

Alternatively for

http://99.88.77.66/~username/controller/index

I get this route not found:

/~username/controller/index

I'm using Rials 4.2.3 and Ruby 2.0.

How can I make my routes work with this kind of subfolder until I can get an appropriate domain name?

回答1:

Try setting config.relative_url_root in config/environments/production.rb:

http://guides.rubyonrails.org/configuring.html#deploy-to-a-subdirectory-relative-url-root