With webrick (i.e. “ruby script/server”) is there a way to alter the
starting
URL? In other words, instead of “http://foo.bar.com”, I’d like it to
start at
“http://foo.bar.com/myapp”?
And, still be on port 3000?
If it’s not possible, that’s fine. Just thought I’d ask.
Is this what you’re after: you browse to http://foo.bar.com, and you
automatically get routed to http://foo.bar.com/myapp? If so, then
yes, it’s possible using the Rails routing system.
You should have a file named config/routes.rb in your project. Edit
that file and look for a line that has:
map.connect ‘’ (note: those are two single-quotes with nothing
between them; it’s easy to mistake them for one double-quote)
In the default routes.rb, this line is commented out, with a comment
above it that talks about routing the root of your site. Uncomment
that line if necessary, and edit it to look like:
map.connect ‘’, :controller => “myapp” (again, that’s two single-quotes)
This say to Rails, “if a request comes in for the root of the site,
use http://foo.bar.com/myapp as the result”. Rails will still prefer
serving the file public/index.html if it exists, no matter what route
you have defined for the site root. Remove (or rename) public/
index.html and you should be good to go.
Hope this helps.
Regards,
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.