Forum: Ruby on Rails Altering the starting URL for webrick

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel B. (Guest)
on 2006-02-07 20:41
(Received via mailing list)
Hi all,

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.

Thanks,

Dan
David R. (Guest)
on 2006-02-08 00:47
(Received via mailing list)
Hi, Dan.

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 topic is locked and can not be replied to.