0

I want to redirect some links that point to my public folder in Rails.

For example:

http://site.com/example should redirect to http://site.com/example/index.html

I only want to do this for the content that is my public folder.

I tried this in the config/routes.rb file:

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

But it enters a redirect loop. So http://site.com/example redirects to to http://site.com/example/index.html which also redirects to http://site.com/example/index.html/index.html and so on.

Ilea Cristian
  • 5,741
  • 1
  • 23
  • 37

1 Answers1

0

For your solution, Create a page controller and define your page action

for example

your controller name is PagesController

class PagesController < ApplicationController
  def about_us
  end
end

create a folder in views, name is pages and create a file that name is about_us. (like - "about_us.html.erb" and write content.

In your route file define

match "/pages/about_us" => "pages#about_us", :as => :about_us"
Dipak Panchal
  • 5,996
  • 4
  • 32
  • 68