Skip to content
/ handler301 Public

Simple rails 301 redirection handler with a config file. Rework your url schema without being worried !

License

Notifications You must be signed in to change notification settings

kwi/handler301

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handler 301

Handler 301 is a plugin for Ruby on Rails that lets you easily manage 301 redirections in on place in order to redirect them to current named routes.

All necessary informations are available on the wiki : wiki.github.com/kwi/handler301

Configuration example :

In the config/handler301.yml of your rails app :

"old_url.html": home_path
"old_url_without_path.html": home
"product_number_one.html": products_path :id => 1

Then, configure a controller that match non matching routes in your config/routes.rb

Rails2

ActionController::Routing::Routes.draw  do |map|
  map.connect "*path", :controller => 'error', :action => 'handle404'
end

Rails3

MkdBaseApp::Application.routes.draw do
  match "*path" => 'error#handle404'
end

And finally, in your ErrorController (or whatever the name of your non matching routes controller) :

class ErrorController < ApplicationController
  def handle404
    unless handle_301(request.path, request.query_parameters)

      # Do your stuff here

    end
  end
end

TODO

  • Change for using Rails metal in order to speed up the mechanism

Copyright © 2010 Guillaume Luccisano - g-mai|: guillaume.luccisano, released under the MIT license

About

Simple rails 301 redirection handler with a config file. Rework your url schema without being worried !

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages