# Cannot set ENV\['RAILS\_RELATIVE\_URL\_ROOT'\]

**URL:** <https://www.ruby-forum.com/t/cannot-set-env-rails-relative-url-root/84879>\
**Category:** Rails\
**Created:** [February 8, 2007, 11:48am UTC](https://www.ruby-forum.com/t/cannot-set-env-rails-relative-url-root/84879 "2007-02-08T11:48:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/b2d939/32.png) [@fero](https://www.ruby-forum.com/u/fero)\
**Post date:** [February 8, 2007, 11:48am UTC](https://www.ruby-forum.com/t/cannot-set-env-rails-relative-url-root/84879/1 "2007-02-08T11:48:22Z")

</div>

i am on lighttpd now, and i cannot set  
cannot set enviroment variable:

i added this line to enviroment.rb, but it doesn not work!!

ENV[‘RAILS\_RELATIVE\_URL\_ROOT’] = ‘something’

links on my page are ok, but all links to images, stylesheets etc are  
broken, (because relative\_url\_root returns ‘’), what else can I do?

thanks. f.

---

<div class="post-metadata">

**Author:** ![fero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/b2d939/32.png) [@fero](https://www.ruby-forum.com/u/fero)\
**Post date:** [March 23, 2009, 3:25am UTC](https://www.ruby-forum.com/t/cannot-set-env-rails-relative-url-root/84879/2 "2009-03-23T03:25:53Z")

</div>

fero wrote:

> i am on lighttpd now, and i cannot set  
> cannot set enviroment variable:
> 
> i added this line to enviroment.rb, but it doesn not work!!
> 
> ENV[‘RAILS\_RELATIVE\_URL\_ROOT’] = ‘something’
> 
> links on my page are ok, but all links to images, stylesheets etc are  
> broken, (because relative\_url\_root returns ‘’), what else can I do?
> 
> thanks. f.

Maybe you can set the

# Reset the asset host

ActionController::Base.asset\_host = Proc.new do |source, request|  
“#{request.protocol}#{request.host\_with\_port}”  
end

---

<div class="post-metadata">

**Author:** ![fero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/b2d939/32.png) [@fero](https://www.ruby-forum.com/u/fero)\
**Post date:** [March 23, 2009, 5:05am UTC](https://www.ruby-forum.com/t/cannot-set-env-rails-relative-url-root/84879/3 "2009-03-23T05:05:24Z")

</div>

On Thu, Feb 8, 2007 at 3:48 AM, fero [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i am on lighttpd now, and i cannot set  
> cannot set enviroment variable:
> 
> i added this line to enviroment.rb, but it doesn not work!!
> 
> ENV[‘RAILS\_RELATIVE\_URL\_ROOT’] = ‘something’
> 
> links on my page are ok, but all links to images, stylesheets etc are  
> broken, (because relative\_url\_root returns ‘’), what else can I do?

See  
[http://rails.lighthouseapp.com/projects/8994/tickets/1946-setting-a-relative-root-url-via-a-web-server-not-possible-anymore](http://rails.lighthouseapp.com/projects/8994/tickets/1946-setting-a-relative-root-url-via-a-web-server-not-possible-anymore)

You must set config.action\_controller.relative\_url\_root = ‘something’  
now instead of using the environment variable.

jeremy
