[Radiant] Redirecting in Radiant

Sean Santry sean at seansantry.com
Fri Sep 1 09:29:27 CDT 2006


Having moved one of my sites to Radiant, I needed to implement  
permanent (301) redirects on some old URLs. Since I'm running under  
Mongrel behind Apache's mod_proxy (on TextDrive), I needed to do  
something at the Radiant level. (This was before mongrel could do  
redirects.)

I decided to patch SiteController to add a redirect_page action:

   def redirect_page
     redirect_to params[:url].to_s
     headers['Status'] = '301 Moved Permanently'
   end

then I added some routes:

   # Site URLs
   map.with_options(:controller => 'site') do |site|

     # snip . . .

     # Redirects for old static-site URLs
     site.connect 'products.htm', :action => 'redirect_page', :url =>  
'/products/'
     site.connect 'products1.htm', :action => 'redirect_page', :url  
=> '/products/'
     site.connect 'samples.htm', :action => 'redirect_page', :url =>  
'/sample-genograms/'

     # etc.

   end

This got me thinking that it might be useful to have a way to specify  
"alias URLs" for a page, much like one currently can specify the slug  
for a page. That way one can define the URLs for a page in Radiant,  
instead of having to edit an Apache htaccess or a lighttpd config  
file (the latter of which requires bouncing the web server).

Would anyone else be interested in this functionality? I may work on  
it just for kicks . . .

- Sean



More information about the Radiant mailing list