From 1f9238bbe7fef6cf4b9da9e211ce65cca3e9f10d Mon Sep 17 00:00:00 2001 From: MrMicky Date: Sun, 7 Aug 2022 17:11:21 +0200 Subject: [PATCH] Support installation in subdirectory with Apache --- .htaccess | 7 ++++--- server.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 server.php diff --git a/.htaccess b/.htaccess index 866ae6a2..0747774d 100644 --- a/.htaccess +++ b/.htaccess @@ -9,8 +9,9 @@ RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] - # Redirect Trailing Slashes... - RewriteRule ^(.*)/$ /public/$1 [L,R=301] + RewriteCond %{REQUEST_FILENAME} -d [OR] + RewriteCond %{REQUEST_FILENAME} -f + RewriteRule ^ ^$1 [N] # Handle assets in the public/ directory RewriteCond %{REQUEST_URI} (\.\w+$) [NC] @@ -19,5 +20,5 @@ # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ public/index.php [L] + RewriteRule ^ server.php [L] diff --git a/server.php b/server.php new file mode 100644 index 00000000..e3aa079b --- /dev/null +++ b/server.php @@ -0,0 +1,19 @@ + + */ +$uri = urldecode( + parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) +); + +// This file allows us to emulate Apache's "mod_rewrite" functionality from the +// built-in PHP web server. This provides a convenient way to test a Laravel +// application without having installed a "real" web server software here. +if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { + return false; +} + +require_once __DIR__.'/index.php';