Hi, I''ve looked for several ways of doing this but none of the methods I have found work correctly. Basically, the website I am writing is navigated to using the standard domain name, i.e. http://website.com/. Using the routes.rb file the root of the website is mapped to a controller called ''home'' so http://website.com/ is the same as http://website.com/home. I however wish to have users that visit http://website.com/ to be redirected (in a way the user can see) to http://website.com/home. I have tried doing this by adding redirect_to to routes.rb, this didn''t work. I have also tried the redirect using .htaccess but unfortunately my skills in this area are rather limited. I have also tried a plugin that didn''t work correctly. Can you help me sort this problem out. Thanks in advance, Alex -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
not necessarily the best way, but you can input an index.html in your public folder and use meta tag to redirect <head> <meta http-equiv="refresh" content="0;url=http://..../home"> </heed> <body> redirecting you to ...../home </body> in any case, why not just http://website.com/ ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pre Rails 2.0: map.connect '''', :controller => "home" Rails 2.0 map.root :controller => "home" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Use redirect to call in ur controller. Http://www.rubyplus.org Free Ruby & Rails screencasts On Feb 16, 2008, at 12:55 PM, Digital Pardoe <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hi, > > I''ve looked for several ways of doing this but none of the methods I > have found work correctly. > > Basically, the website I am writing is navigated to using the standard > domain name, i.e. http://website.com/. Using the routes.rb file the > root > of the website is mapped to a controller called ''home'' so > http://website.com/ is the same as http://website.com/home. > > I however wish to have users that visit http://website.com/ to be > redirected (in a way the user can see) to http://website.com/home. > > I have tried doing this by adding redirect_to to routes.rb, this > didn''t > work. I have also tried the redirect using .htaccess but unfortunately > my skills in this area are rather limited. I have also tried a plugin > that didn''t work correctly. > > Can you help me sort this problem out. > > Thanks in advance, > Alex > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, rubynuby wrote:> not necessarily the best way, but you can input an index.html in your > public folder and use meta tag to redirect > > <head> > <meta http-equiv="refresh" content="0;url=http://..../home"> > </heed> > <body> > redirecting you to ...../home > </body> > > in any case, why not just http://website.com/ ?I didn''t want it to be quite that messy, although I suppose it will get the job done. Ryan Bigg wrote:> Pre Rails 2.0: > > map.connect '''', :controller => "home" > > Rails 2.0 > > map.root :controller => "home"I realize this, but it doesn''t really answer the question. Bcp wrote:> Use redirect to call in ur controller. > > Http://www.rubyplus.org > Free Ruby & Rails screencasts > > > On Feb 16, 2008, at 12:55 PM, Digital Pardoe > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.orgI tried redirect but it didn''t work, can you give me a little code help, context etc, or do I just put it anywhere? ;-). Thanks, Alex -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Did my reply get lost? map.root :controller => "home" Stick that in your config/routes.rb file and it''ll do just what you want it to do! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Did my reply get lost? > > map.root :controller => "home" > > Stick that in your config/routes.rb file and it''ll do just what you want > it > to do!Erm, your reply didn''t get lost, ''map.root'' is merely an alias for; map.connect '''', controller => "home" It still doesn''t physically redirect the user so they see http://website.com/home in their address bar. I have however given you the benefit of the doubt and tried it, it didn''t work. Alex -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I understand what you want to do but would that confuse the user? If I went to att.com and then was redirected i would wonder why. Is this a site someone would log into? Just curious. John I On Feb 17, 8:03 am, Digital Pardoe <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Ryan Bigg wrote: > > Did my reply get lost? > > > map.root :controller => "home" > > > Stick that in your config/routes.rb file and it''ll do just what you want > > it > > to do! > > Erm, your reply didn''t get lost, ''map.root'' is merely an alias for; > > map.connect '''', controller => "home" > > It still doesn''t physically redirect the user so they seehttp://website.com/homein their address bar. > > I have however given you the benefit of the doubt and tried it, it > didn''t work. > > Alex > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
John Ivanoff wrote:> I understand what you want to do but would that confuse the user? If I > went to att.com and then was redirected i would wonder why. > Is this a site someone would log into? > > Just curious. > > John I > > On Feb 17, 8:03�am, Digital Pardoe <rails-mailing-l...@andreas-s.net>I''m really just after doing if for the sake of consistency, the blog is accessed by /blog, photos by /photography, so why shouldn''t home be accessed with /home. It may also be something useful to add to my Rails armory, and might come up again in the future for different purposes. Thanks, Alex -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
someone correct me if i''m really wrong, but i believe that what is missing from the conversation is this: when you do something like map.root, :controller=>"home", :action=>"index" (if you want to specify action) then you have a new named route, called root so if you want to go back to the root of the application then what would be www.mysite.com is actually www.mitesite.com/home... throughout your app you can then use something like this: link_to root_path or link_to root_url those are nice little guys that will do the named route business for you. Then you can be nice and DRY and not actually specify your domain at all, but let your application figure that part out for you. Is that a help? On Feb 17, 4:24 pm, Digital Pardoe <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> John Ivanoff wrote: > > I understand what you want to do but would that confuse the user? If I > > went to att.com and then was redirected i would wonder why. > > Is this a site someone would log into? > > > Just curious. > > > John I > > > On Feb 17, 8:03�am, Digital Pardoe <rails-mailing-l...@andreas-s.net> > > I''m really just after doing if for the sake of consistency, the blog is > accessed by /blog, photos by /photography, so why shouldn''t home be > accessed with /home. It may also be something useful to add to my Rails > armory, and might come up again in the future for different purposes. > > Thanks, > Alex > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Digital Pardoe wrote:> > It still doesn''t physically redirect the user so they see > http://website.com/home in their address bar. > > I have however given you the benefit of the doubt and tried it, it > didn''t work.It makes sense that you don''t want two URIs on your site to have identical content. Here is a somewhat kludgy way to do this - in routes.rb: map.root :controller => ''home'', :action => ''redirect'' Then in the home_controller.rb: def redirect redirect_to url_for(:controller => ''home'', :action => ''index'') end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Mcc wrote:> Digital Pardoe wrote: >> >> It still doesn''t physically redirect the user so they see >> http://website.com/home in their address bar. >> >> I have however given you the benefit of the doubt and tried it, it >> didn''t work. > > It makes sense that you don''t want two URIs on your site to have > identical content. > > Here is a somewhat kludgy way to do this - in routes.rb: > > map.root :controller => ''home'', :action => ''redirect'' > > Then in the home_controller.rb: > > def redirect > redirect_to url_for(:controller => ''home'', :action => ''index'') > endHi: 1.in Configure/routes.rb add a command: map.root :controller => "home" 2.delete public/index.html . Or it will not happen. Cruise -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---