# Solution for installing Radiant in a subdirectory

**URL:** <https://www.ruby-forum.com/t/solution-for-installing-radiant-in-a-subdirectory/75462>\
**Category:** Radiant CMS\
**Created:** [November 10, 2006, 12:31am UTC](https://www.ruby-forum.com/t/solution-for-installing-radiant-in-a-subdirectory/75462 "2006-11-10T00:31:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roydon\_Gyles-Bedfor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b4bc9f/32.png) [@Roydon\_Gyles-Bedfor](https://www.ruby-forum.com/u/Roydon_Gyles-Bedfor)\
**Post date:** [November 10, 2006, 12:31am UTC](https://www.ruby-forum.com/t/solution-for-installing-radiant-in-a-subdirectory/75462/1 "2006-11-10T00:31:24Z")

</div>

My set up:  
Radiant is running under mongrel with the prefix flag. --prefix /sub/dir  
This makes /admin work ([example.com/sub/dir/admin](http://example.com/sub/dir/admin)). (This also works  
when Apache is proxying to mongrel, and mongrel has the prefix flag)

In environment.rb, I have added  
ActionController::AbstractRequest.relative\_url\_root = “/sub/dir”

The changes to Radiant that are required was actually very simple once i  
figured out where/how to do it.

In models/page\_context.rb I added this method:  
define\_tag ‘url’ do |tag|  
“#{ActionController::AbstractRequest.relative\_url\_root}#{tag.locals.page.send(:url)}”  
end

and i removed the ‘+ [:url]’ from  
((@page.attributes.symbolize\_keys.keys + [:url]) - [:created\_by,  
:updated\_by]).each do |method|

This also works when ActionController::AbstractRequest.relative\_url\_root  
is not defined, because it’ll return “”.

This way any calls to \<r:url\>, \<r:link\>, etc generate urls with the  
prefix.

I haven’t fully tested this, but so far everything seems to work fine.

Roydon G-B

---

<div class="post-metadata">

**Author:** ![Roydon\_Gyles-Bedfor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b4bc9f/32.png) [@Roydon\_Gyles-Bedfor](https://www.ruby-forum.com/u/Roydon_Gyles-Bedfor)\
**Post date:** [November 10, 2006, 12:42am UTC](https://www.ruby-forum.com/t/solution-for-installing-radiant-in-a-subdirectory/75462/2 "2006-11-10T00:42:59Z")

</div>

Actually, it might be more appropriate to adjust the Page model to  
return its full url with the relative\_url\_root prepended. Interesting  
solution!

Sean C.  
[seancribbs.com](http://seancribbs.com)
