I have some resources in my routes file:
resources :snippets
resources :pastes
Users can access a snippet like this:
/snippets/72384
/pastes/ac6Xs28
As a short-hand, for tweets, IRC, etc… I want /s/<id> to be redirected to /snippets/<id>, and /p/<id> to /pastes/<id>. I want this redirection to use the Location HTTP header and the 301 Moved Permanently HTTP status code.
How am I about to do this? Thanks.
I’m using Rails 3 with WEBrick
You can do it in
routes.rbHere’s a nice overview of routing in Rails3.