From 240213177eba35921f9ee621e8865311b94f6d21 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Sat, 18 Mar 2006 16:45:40 +0000 Subject: Add ability for relative_url_root to be specified via an environment variable RAILS_RELATIVE_URL_ROOT. Closes #4243. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3931 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/request.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller/request.rb') diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 3bfc8f9385..566ae42ba0 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -163,9 +163,18 @@ module ActionController end # Returns the path minus the web server relative installation directory. - # This method returns nil unless the web server is apache. + # This can be set with the environment variable RAILS_RELATIVE_URL_ROOT. + # It can be automatically extracted for Apache setups. If the server is not + # Apache, this method returns an empty string. def relative_url_root - @@relative_url_root ||= server_software == 'apache' ? @env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') : '' + @@relative_url_root ||= case + when @env["RAILS_RELATIVE_URL_ROOT"] + @env["RAILS_RELATIVE_URL_ROOT"] + when server_software == 'apache' + @env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') + else + '' + end end # Returns the port number of this request as an integer. -- cgit v1.2.3