Saturday, September 6, 2008

router redirects

Merb's router supports a nice redirect feature:

r.match('/old-invalid-url').redirect("/hawt-new-goodness")

One item of note--this redirect defaults to a 301 status, so if you're playing around with this and want 302's instead, pass a false as a second parameter to redirect:

r.match('/').redirect("/login", false)

If you happen to confuse this and set a permanent 301, just add in the false, hit the page again, let the 302 be processed, and you should be good after taking out the redirect again.

No comments: