From 1e88e8086f9db19ae7782b12f06e9c47dd772240 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Bouc=CC=8Cek?= <pan@jakubboucek.cz>
Date: Wed, 23 Sep 2020 01:22:03 +0200
Subject: [PATCH] Fixed canonical redirects on non-root url app instances

If BookStack instance is deployed to any non-root path, e.g. http://example.com/wiki/,
requests for http://example.com/wiki/shelves/
was redirected to http://example.com/shelves
instead of http://example.com/wiki/shelves

Synced with: https://github.com/laravel/laravel/blob/master/public/.htaccess
---
 public/.htaccess | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/public/.htaccess b/public/.htaccess
index abe87b39d..3aec5e27e 100644
--- a/public/.htaccess
+++ b/public/.htaccess
@@ -11,9 +11,10 @@
 
     # Redirect Trailing Slashes If Not A Folder...
     RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteRule ^(.*)/$ /$1 [L,R=301]
+    RewriteCond %{REQUEST_URI} (.+)/$
+    RewriteRule ^ %1 [L,R=301]
 
-    # Handle Front Controller...
+    # Send Requests To Front Controller...
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^ index.php [L]