Bug 21031: Apache Rewrite rules don't work for API when using anything but Debian...
authorDavid Cook <dcook@prosentient.com.au>
Tue, 3 Jul 2018 09:04:50 +0000 (19:04 +1000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 2 Aug 2018 13:23:08 +0000 (10:23 -0300)
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 <ere.maijala@helsinki.fi>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Passed QA with few notes posted separately to Bugzilla.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

debian/templates/apache-shared-intranet.conf
debian/templates/apache-shared-opac.conf
etc/koha-httpd.conf

index e1aef5e..1d34705 100644 (file)
@@ -27,8 +27,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]
 </Directory>
index 7adcb4a..2a7e9ac 100644 (file)
@@ -34,8 +34,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]
 </Directory>
index 6f51ace..d0f619e 100644 (file)
 
        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]
+
      </Directory>
    </IfModule>
 
 
        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]
      </Directory>
    </IfModule>