I am new to ruby, can any one help me in explaining "how to change htt开发者_运维问答p://www.myexample.com:3000 to http://wwww.myexample.com in ruby?"
require 'uri'
uri = URI.parse('http://www.myexample.com:3000')
uri.port = nil
uri.host.sub!('www', 'wwww')
uri.to_s # => http://wwww.myexample.com
Depends on what web server you're using, but in general, try adding a -p 80
option to the command line when starting up the web server.
For example, with the Thin web server, you'd run: thin -p 80 start
.
Assuming your using webrick, pass --port 80
on the command line when running your server
port 3000 is the rails server default port. You can avoid this 3000 by getting your rails app behind apache/ passenger (normally the production setup)
By that way apache and passenger will do the routings and you can view your app at http://www.example.com
Following will be helpful
passenger - http://www.modrails.com/ rails casts - http://railscasts.com/episodes/122-passenger-in-development
hope this helps
cheers
sameera
精彩评论