Sha256: abd7b435deb81693afd9405056db2471e773e5a8ec74d41e5f95a325b75a3954

Contents?: true

Size: 520 Bytes

Versions: 9

Compression:

Stored size: 520 Bytes

Contents

class RedirectController < ContentController
  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

9 entries across 9 versions & 1 rubygems

Version Path
typo-3.99.0 app/controllers/redirect_controller.rb
typo-3.99.1 app/controllers/redirect_controller.rb
typo-3.99.3 app/controllers/redirect_controller.rb
typo-3.99.2 app/controllers/redirect_controller.rb
typo-4.0.0 app/controllers/redirect_controller.rb
typo-4.0.2 app/controllers/redirect_controller.rb
typo-4.0.1 app/controllers/redirect_controller.rb
typo-3.99.4 app/controllers/redirect_controller.rb
typo-4.0.3 app/controllers/redirect_controller.rb