views:

148

answers:

2

I recently changed some URLs in my Rails app and am curious if I'm better off using routes + controllers + redirect_to to forward the old URLs, or just use .htaccess with Apache's mod_rewrite?

I'm using Apache + Passenger so htaccess files work, but was curious if there was a standard for this sort of thing.

FWIW, the URLs were changed from this: http://example.com/user/joeschmoe

to this: http://example.com/joeschmoe

+2  A: 

I personally would perform the rewrite using mod_rewrite, because it should be faster than loading rails and performing a redirect there.

If you're really concerned about performance (and you manage your own webserver), you could build the rewrite rules (and whatever else you have in your .htaccess) into the httpd.conf file and disable overrides (disabling your .htaccess files). This will give you a slight performance boost in serving all of your requests.

Kenaniah
+2  A: 
John Topley
+1 I didn't know about Refraction. Really cool project.
Simone Carletti