I want to move my site elsewhere. So I thought I could throw in a
Webrick instance to serve as a 301 redirector on the old port and send
all the traffic to the new site. I’ve got the headers[“status”]=“301
moved permanently” and the redirect_to “http://www.newsite.com” but
what’s happening is that the basic URL (mysite.com/blog) is being
redirected (my controller is /blog), but more complex urls like
/blog/2005/09/07/abc.html are getting a “recognition failed” error.
Makes sense since there is no “2005” action.
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 ?
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 ?
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.