From 4cd7ee0c0c2be2cd2e2284d49a74f51955baf503 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Sun, 30 Oct 2022 22:47:55 -0700 Subject: [PATCH] Detect when running Apache without .htaccess And throw an exception --- src/bb-load.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bb-load.php b/src/bb-load.php index 2205a836d..e4ca3ed3a 100644 --- a/src/bb-load.php +++ b/src/bb-load.php @@ -308,3 +308,12 @@ if ($config['debug']) { ini_set('log_errors', '1'); ini_set('html_errors', false); ini_set('error_log', BB_PATH_LOG.'/php_error.log'); + +$isApache = (function_exists("apache_get_version")) ? true : false; +$serverSoftware = (isset($_SERVER["SERVER_SOFTWARE"])) ? $_SERVER["SERVER_SOFTWARE"] : ""; + +if($isApache or (stripos($serverSoftware, 'apache') !== false) ){ + if(!file_exists(BB_PATH_ROOT . '/.htaccess')){ + throw new Exception('Error: You appear to be running an Apache server without a valid .htaccess file. You may need to rename htaccess.txt to .htaccess'); + } +}