Skip to content

Commit

Permalink
Fix problems with rewriting under centos
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Jul 2, 2013
1 parent c5b745f commit de1bdbe
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ function errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext)
}
set_error_handler('errorHandler');

/*
* method to get evironment variables which are prefixed with "REDIRECT_"
* in some configurations Apache prefixes the environment variables on each rewrite walkthrough
* e.g. under centos
*/
function getEnvVar ($key)
{
$prefix = "REDIRECT_";
if (isset($_SERVER[$key])) {
return $_SERVER[$key];
}
foreach ($_SERVER as $k => $v) {
if (substr($k, 0, strlen($prefix)) == $prefix) {
if (substr($k, -(strlen($key))) == $key) {
return $v;
}
}
}
return null;
}

/**
* Bootstrap constants
* @since 0.9.5
Expand Down Expand Up @@ -82,8 +103,9 @@ function errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext)
// TODO: check for AllowOverride All
$rewriteEngineOn = false;

if (isset($_SERVER['ONTOWIKI_APACHE_MOD_REWRITE_ENABLED'])) {
if (getEnvVar('ONTOWIKI_APACHE_MOD_REWRITE_ENABLED')) {
// used in .htaccess or in debian package config
// in some configurations Apache prefixes the env var with 'REDIRECT_'
$rewriteEngineOn = true;
} else if (function_exists('__virt_internal_dsn')) {
// compatible with Virtuoso VAD
Expand Down

0 comments on commit de1bdbe

Please sign in to comment.