From 92473b8f961218284340f4d045ba8fe3cbd694b1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 18 Jun 2005 05:17:18 +0000 Subject: Fixed relative urls support for lighttpd #1048 [Nicholas Seckar/maznawak@nerim.net] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1450 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/request.rb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 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 2cb4377273..73247d510a 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -135,12 +135,17 @@ module ActionController # Returns the interpreted path to requested resource after all the installation directory of this application was taken into account def path path = (uri = request_uri) ? uri.split('?').first : '' - path[relative_url_root.length..-1] # cut off the part of the url which leads to the installation directory of this app + + # Cut off the path to the installation directory if given + if (root = relative_url_root) then path[root.length..-1] + else path + end end - # Returns the path minus the web server relative installation directory - def relative_url_root(force_reload = false) - @@relative_url_root ||= File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') + # Returns the path minus the web server relative installation directory. + # This method returns nil unless the web server is apache. + def relative_url_root + @@relative_url_root ||= File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') if server_software == 'apache' end def port @@ -165,6 +170,10 @@ module ActionController @path_parameters ||= {} end + def server_software + (env['SERVER_SOFTWARE'] && /^([a-zA-Z]+)/ =~ env['SERVER_SOFTWARE']) ? $1.downcase : nil + end + #-- # Must be implemented in the concrete request #++ -- cgit v1.2.3