[Radiant] Redirecting in Radiant

Sean Cribbs seancribbs at gmail.com
Fri Sep 1 09:39:07 CDT 2006


A short behavior could do the trick, since you have direct access to the
response object.  This might work:

class RedirectBehavior < Behavior::Base

  register "Redirect Permanently"

  description %{ Redirects to another page. }

  def process(request, response)
    response.headers["Status"] = "301 Moved Permanently"
    response.redirect(page.page_config["url"])
    request, response = nil, nil
  end

end

Cheers!

Sean Cribbs
seancribbs.com
On 9/1/06, Sean Santry <sean at seansantry.com> wrote:
>
> 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
> _______________________________________________
> Radiant mailing list
> Radiant at lists.radiantcms.org
> http://lists.radiantcms.org/mailman/listinfo/radiant
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.radiantcms.org/pipermail/radiant/attachments/20060901/0b24d393/attachment.html


More information about the Radiant mailing list