# Redirecting in Radiant

**URL:** <https://www.ruby-forum.com/t/redirecting-in-radiant/67243>\
**Category:** Radiant CMS\
**Created:** [September 1, 2006, 4:30pm UTC](https://www.ruby-forum.com/t/redirecting-in-radiant/67243 "2006-09-01T16:30:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [September 1, 2006, 4:30pm UTC](https://www.ruby-forum.com/t/redirecting-in-radiant/67243/1 "2006-09-01T16:30:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![df-sean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@df-sean](https://www.ruby-forum.com/u/df-sean)\
**Post date:** [September 1, 2006, 4:40pm UTC](https://www.ruby-forum.com/t/redirecting-in-radiant/67243/2 "2006-09-01T16:40:32Z")

</div>

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 C.  
[seancribbs.com](http://seancribbs.com)
