Sha256: e15445bb3760d1aab8e6ff0c55625927a0f67cd557b88d24f7d5b5885d92e962

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 Bytes

Contents

class RedirectController < ContentController
  session :off

  def redirect
    r = Redirect.find_by_from_path(params[:from])

    if(r)
      # From http://pinds.com/articles/2005/11/06/rails-how-to-do-a-301-redirect, thanks
      headers["Status"] = "301 Moved Permanently"
      path = r.to_path
      url_root = request.relative_url_root
      path = url_root + path unless url_root.nil? or path[0,url_root.length] == url_root
      redirect_to path
    else
      render :text => "Page not found", :status => 404
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typo-4.1.1 app/controllers/redirect_controller.rb
typo-4.1 app/controllers/redirect_controller.rb