how to do url rewriting

You can add a custom route to do that, but with the pattern you suggest, it may be tough to add other controllers as it breaks many rails conventions.

in Rails 2.3's routes.rb file:

map.edit_user ":id", :controller => "users", :action => "edit", :id => /\d/

The regex on ID is to prevent this route from matching other routes you may have in your app that follow Rails conventions. It ensures the ID is a number. You would also need to remove the "edit" route from the user resource by adding :except => [:edit].

But I strongly urge against this. With the pattern you've described wanting to apply to all URLs, the routing engine will have no way to determine what you actually want it to do for example:

GET http://localhost:3000/30

Does that reference the edit action for the users controller for id 30, or the show action for posts with id 30, or the show action for users with id 30, etc?

With such a short url, ambiguity and difficulty in growing the app for the url collisions is what you will have.