From 11b6ad197ab279aca89944001a9751a492bdb573 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 3 Jul 2018 19:04:50 +1000 Subject: [PATCH] Bug 21031: Apache Rewrite rules don't work for API when using anything but Debian package Plack configuration The Rewrite rules for Apache don't work unless you're using debian/templates/apache-shared-opac-plack.conf or debian/templates/apache-shared-intranet-plack.conf. This patch fixes the Rewrite rules for the non-Plack Debian Apache configuration templates as well as the standard Apache configuration file that comes with Koha. __BEFORE APPLYING__ 1. Visit /api/v1/app.pl/api/v1/spec on your git dev install 2. This should display a large page of JSON 3. Visit /api/v1/spec on your git dev install 4. This should generate a 404 error __APPLY PATCH__ __AFTER APPLYING__ 5. Visit /api/v1/app.pl/api/v1/spec on your git dev install 6. This should display a large page of JSON 7. Visit /api/v1/spec on your git dev install 8. This should display a large page of JSON (identical to the one from earlier steps) Signed-off-by: Ere Maijala Signed-off-by: Marcel de Rooy Passed QA with few notes posted separately to Bugzilla. Signed-off-by: Tomas Cohen Arazi (cherry picked from commit c6b50f0bac092779f93033c8a3f002cb8722d7d4) Signed-off-by: Martin Renvoize --- debian/templates/apache-shared-intranet.conf | 6 ++---- debian/templates/apache-shared-opac.conf | 6 ++---- etc/koha-httpd.conf | 13 +++++-------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/debian/templates/apache-shared-intranet.conf b/debian/templates/apache-shared-intranet.conf index 8b98777e42..a5600ecc82 100644 --- a/debian/templates/apache-shared-intranet.conf +++ b/debian/templates/apache-shared-intranet.conf @@ -28,8 +28,6 @@ Alias "/api" "/usr/share/koha/api" SetEnv MOJO_MODE "production" RewriteBase /api/ - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f - RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L] + RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl + RewriteRule ^(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L] diff --git a/debian/templates/apache-shared-opac.conf b/debian/templates/apache-shared-opac.conf index 61f2467afd..7987a926af 100644 --- a/debian/templates/apache-shared-opac.conf +++ b/debian/templates/apache-shared-opac.conf @@ -35,8 +35,6 @@ Alias "/api" "/usr/share/koha/api" SetEnv MOJO_MODE "production" RewriteBase /api/ - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f - RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L] + RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl + RewriteRule ^(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L] diff --git a/etc/koha-httpd.conf b/etc/koha-httpd.conf index 40c2b45cab..6428e79386 100644 --- a/etc/koha-httpd.conf +++ b/etc/koha-httpd.conf @@ -124,10 +124,9 @@ RewriteEngine On RewriteBase /api/ - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f - RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L] + RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl + RewriteRule ^(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L] + @@ -252,10 +251,8 @@ RewriteEngine On RewriteBase /api/ - RewriteCond %{REQUEST_FILENAME} !-f - RewriteCond %{REQUEST_FILENAME} !-d - RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f - RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L] + RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl + RewriteRule ^(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L] -- 2.39.5