From a5dcb8599b5c1d9001632acf06499db2f2dca208 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 22 Mar 2017 12:15:06 -0400 Subject: [PATCH] LP#1648234: fix Apache 2.2 version of redirect rules Apache 2.2 doesn't actually set a REQUEST_SCHEME variable, so we'll simulate it. Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson Signed-off-by: Ben Shum Signed-off-by: Galen Charlton --- Open-ILS/examples/apache/eg_vhost.conf.in | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Open-ILS/examples/apache/eg_vhost.conf.in b/Open-ILS/examples/apache/eg_vhost.conf.in index 576f454d55..f2aba579bf 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf.in +++ b/Open-ILS/examples/apache/eg_vhost.conf.in @@ -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 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] AddOutputFilter INCLUDES;XMLENT .html -- 2.43.2