LP#1648234: fix Apache 2.2 version of redirect rules
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 22 Mar 2017 16:15:06 +0000 (12:15 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 11 May 2017 18:43:48 +0000 (14:43 -0400)
Apache 2.2 doesn't actually set a REQUEST_SCHEME variable,
so we'll simulate it.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Ben Shum <ben@evergreener.net>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/examples/apache/eg_vhost.conf.in

index 576f454..f2aba57 100644 (file)
@@ -3,10 +3,19 @@
 # through all virtual hosts (port 80, port 443, etc.) should live in here.
 # ----------------------------------------------------------------------------------
 
+# Since Apache 2.2 doesn't set REQUEST_SCHEME, work around it
+# by setting an environment variable, per
+# http://stackoverflow.com/a/23177714
+RewriteCond %{HTTPS} off
+RewriteRule .* - [E=REQUEST_SCHEME:http]
+
+RewriteCond %{HTTPS} on
+RewriteRule .* - [E=REQUEST_SCHEME:https]
+
 # ----------------------------------------------------------------------------------
 # Point / to the opac - if you have a custom skin or locale, point at it here
 # ----------------------------------------------------------------------------------
-RewriteRule ^/$ %{REQUEST_SCHEME}://%{HTTP_HOST}/eg/opac/home [R=301,L]
+RewriteRule ^/$ %{ENV:REQUEST_SCHEME}://%{HTTP_HOST}/eg/opac/home [R=301,L]
 
 # ----------------------------------------------------------------------------------
 # Redirect staff to the correct URL if they forget to include the final /
@@ -34,8 +43,8 @@ RewriteRule ^/eg/staff$ https://%{HTTP_HOST}/eg/staff/ [R=301,L]
 # ----------------------------------------------------------------------------------
 # Assign a default locale to the accessible OPAC
 # ----------------------------------------------------------------------------------
-RewriteRule ^/opac/extras/slimpac/start.html$ %{REQUEST_SCHEME}://%{HTTP_HOST}/opac/en-US/extras/slimpac/start.html [R=301,L]
-RewriteRule ^/opac/extras/slimpac/advanced.html$ %{REQUEST_SCHEME}://%{HTTP_HOST}/opac/en-US/extras/slimpac/advanced.html [R=301,L]
+RewriteRule ^/opac/extras/slimpac/start.html$ %{ENV:REQUEST_SCHEME}://%{HTTP_HOST}/opac/en-US/extras/slimpac/start.html [R=301,L]
+RewriteRule ^/opac/extras/slimpac/advanced.html$ %{ENV:REQUEST_SCHEME}://%{HTTP_HOST}/opac/en-US/extras/slimpac/advanced.html [R=301,L]
 
 # ----------------------------------------------------------------------------------
 # Configure the gateway and translator
@@ -284,7 +293,7 @@ Options -Indexes
 </LocationMatch>
 
 RewriteCond %{QUERY_STRING} locale=([^&]*)
-RewriteRule ^/opac/[a-z]{2}-[A-Z]{2}/extras/slimpac/(.*)$ %{REQUEST_SCHEME}://%{HTTP_HOST}/opac/%1/extras/slimpac/$1? [redirect]
+RewriteRule ^/opac/[a-z]{2}-[A-Z]{2}/extras/slimpac/(.*)$ %{ENV:REQUEST_SCHEME}://%{HTTP_HOST}/opac/%1/extras/slimpac/$1? [redirect]
 <LocationMatch /opac/[a-z]{2}-[A-Z]{2}/extras/slimpac/>
     AddOutputFilter INCLUDES;XMLENT .html
 </LocationMatch>