Skip to content

Commit

Permalink
Merge pull request #6911 from ChurchCRM/6910-bug-minor-mod_rewrite-pr…
Browse files Browse the repository at this point in the history
…esence-not-properly-detected-when-using-cgi-instead-of-apache-module

Add additional method to check for mod_rewrite
  • Loading branch information
DAcodedBEAT authored Mar 24, 2024
2 parents cc97add + 8f4e023 commit fcab566
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ChurchCRM/Service/AppIntegrityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,20 @@ public static function hasModRewrite(): bool
$logger = LoggerUtils::getAppLogger();

if (isset($_SERVER['HTTP_MOD_REWRITE'])) {
$logger->debug("Webserver configuration has set mod_rewrite variable: {$_SERVER['HTTP_MOD_REWRITE']}");
$logger->info("Webserver configuration has set mod_rewrite variable: {$_SERVER['HTTP_MOD_REWRITE']}");
$check = strtolower($_SERVER['HTTP_MOD_REWRITE']) === 'on';
} elseif (stristr($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
$logger->debug('PHP is running through Apache; looking for mod_rewrite');
$logger->info('PHP is running through Apache; looking for mod_rewrite');
if (function_exists('apache_get_modules')) {
$check = in_array('mod_rewrite', apache_get_modules());
}
$logger->debug("Apache mod_rewrite check status: $check");
$logger->info("Apache mod_rewrite check status: $check");
if (empty($check)) {
if (!empty(shell_exec('/usr/sbin/apachectl -M | grep rewrite'))) {
$logger->info('Found rewrite module enabled using apachectl');
$check = true;
}
}
} else {
$logger->debug('PHP is not running through Apache');
}
Expand Down

0 comments on commit fcab566

Please sign in to comment.