gustav paul
2006-Feb-19 20:11 UTC
[Rails] action.controller.domain instead of dmn/cntrlr/action ?
Hey, I want my users to be able to use the following notation: -- http://id.action.controller.domain.com/ instead of having to type in the standard Rails: -- http://domain.com/controller/action/id How can I do this? Is it even possible? If not, don''t you think this is something that the core team should have a look at? (PS. I''m using MySQL for backend and developed using RAILS v1.0 ) Lots of thanks!!! Gustav Paul gustav@psychohistorian.org -- Posted via http://www.ruby-forum.com/.
Jim Cheetham
2006-Feb-19 20:47 UTC
[Rails] action.controller.domain instead of dmn/cntrlr/action ?
On Sun, Feb 19, 2006 at 09:11:19PM +0100, gustav paul wrote:> I want my users to be able to use the following notation: > -- http://id.action.controller.domain.com/ > > instead of having to type in the standard Rails: > -- http://domain.com/controller/action/idA rewrite by your webserver would do this. You need to provide wildcards entries for DNS and the webserver to even get started, and then use mod_rewrite to change the host name into a host+url. Read the mod_rewrite docs, lookinf for "Virtual User Hosts" examples. http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html An untested suggestion would be ... RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+\.[^.]+\.domain\.com$ RewriteRule ^([^.]+)\.([^.]+)\.([^.]+)\.domain\.com(.*) http://domain.com/$3/$2/$1 -jim