【问题标题】:Heroku: Redirect / to /featuresHeroku:重定向/到/功能
【发布时间】:2010-12-01 22:36:42
【问题描述】:

如何自动将访问 mysite.com/ 的每个用户重定向到 mysite.com/features?

谢谢

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 heroku


    【解决方案1】:

    设置您的根路线以指导那里的人(这些是 Rails 3 路线):

    在 config/routes.rb 中

    root "content#features"
    

    在 app/controllers/contents_controller.rb 中

    class ContentsController < ApplicationController
      def features
      end
    end
    

    但是,这不会进行重定向。为此,您需要这样的东西: 在 config/routes.rb 中

    match "features" => "contents#features", :as => "features"
    root "content#index"
    

    在 app/controllers/contents_controller.rb 中

    class ContentsController < ApplicationController
      def index
        redirect_to features_url
      end
      def features
    
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      • 2013-12-20
      • 2020-06-04
      • 2011-07-17
      相关资源
      最近更新 更多