first commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<IfModule mod_headers.c>
|
||||
Header set X-Response-Header-Test: test
|
||||
</IfModule>
|
||||
@@ -0,0 +1 @@
|
||||
hi
|
||||
@@ -0,0 +1,9 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
|
||||
# Testing if we can pass environment variable from .htaccess to script in a RewriteRule
|
||||
# We pass document root, because that can easily be checked by the script
|
||||
|
||||
RewriteEngine On
|
||||
RewriteRule ^test\.php$ - [E=PASSTHROUGHENV:%{DOCUMENT_ROOT},L]
|
||||
|
||||
</IfModule>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Get environment variable set with mod_rewrite module
|
||||
* Return false if the environment variable isn't found
|
||||
*/
|
||||
function getEnvPassedInRewriteRule($envName) {
|
||||
// Environment variables passed through the REWRITE module have "REWRITE_" as a prefix
|
||||
// (in Apache, not Litespeed, if I recall correctly).
|
||||
// Multiple iterations causes multiple REWRITE_ prefixes, and we get many environment variables set.
|
||||
// We simply look for an environment variable that ends with what we are looking for.
|
||||
// (so make sure to make it unique)
|
||||
$len = strlen($envName);
|
||||
foreach ($_SERVER as $key => $item) {
|
||||
if (substr($key, -$len) == $envName) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = getEnvPassedInRewriteRule('PASSTHROUGHENV');
|
||||
if ($result === false) {
|
||||
echo '0';
|
||||
exit;
|
||||
}
|
||||
echo ($result == $_SERVER['DOCUMENT_ROOT'] ? '1' : '0');
|
||||
Reference in New Issue
Block a user