0

publicRailsの自分のフォルダーを指すリンクをいくつかリダイレクトしたいと考えています。

例えば:

http://site.com/exampleにリダイレクトする必要がありますhttp://site.com/example/index.html

パブリック フォルダーであるコンテンツに対してのみこれを実行したいと考えています。

config/routes.rb ファイルでこれを試しました:

 match "*pages" => redirect("/%{pages}/index.html")

しかし、リダイレクトループに入ります。そのため、http://site.com/exampleリダイレクトhttp://site.com/example/index.html先もリダイレクト先などにリダイレクトさhttp://site.com/example/index.html/index.htmlれます。

4

1 に答える 1

0

ソリューションの場合、ページ コントローラーを作成し、ページ アクションを定義します。

例えば

あなたのコントローラー名はPagesController

class PagesController < ApplicationController
  def about_us
  end
end

にフォルダーを作成しviewspages名前は about_us という名前のファイルを作成します。(「about_us.html.erb」のようにコンテンツを書きます。

ルートファイルで定義します

match "/pages/about_us" => "pages#about_us", :as => :about_us"
于 2012-12-04T05:22:30.623 に答える