RE: [Rails] Making a 301 redirector for *everything*

Is there a trick I need to do in order to send every url from the old
site to the new one? While I'm in there, since my url pattern will be
staying the same, am I going to be able to keep that information as

part

of the redirect or do I have to redirect to the main page of my new
site? In other words can I go from

oldsite.com/blog/2005/09/07/abc.html

to newsite.com/2005/09/07/abc.html ?

Thanks!

# Static content control
map.connect '/protected/*path', :controller => 'protected',
                                  :action => 'render_static'

I use this to force any /protected URL to controller protected, action
static. I suspect you could (not tested)

Map.connect '/*path', :controller => 'redirect', action => 'redirect'

This map should put the whole URL in to params[:path], and call
controller redirect, method redirect for every one. You should be able
to construct an appropriate redirect from that.

Be sure to clear out /public so that rails gets the hits.

A simpler way might be to configure a redirect in your web server.
Apache and lighty can do this.

Regards,
Rich

> Is there a trick I need to do in order to send every url
from the old
> site to the new one? While I'm in there, since my url
pattern will be
> staying the same, am I going to be able to keep that information as
part
> of the redirect or do I have to redirect to the main page of my new
> site? In other words can I go from
oldsite.com/blog/2005/09/07/abc.html
> to newsite.com/2005/09/07/abc.html ?
>
> Thanks!

A simpler way might be to configure a redirect in your web server.
Apache and lighty can do this.

Agreed. If you have apache, this is a 3-line .htaccess file in your
webroot:

  RewriteEngine on
  RewriteCond %{HTTP_HOST} oldsite.com
  RewriteRule ^(.*) http://www.newsite.com$1

An even simpler way is to re-point oldsite.com to newsite.com in DNS,
unless you specifically wanted the 301 step inbetween.

- Mark.