note 78597 deleted from function.preg-replace by crell
| From: | crell@php.net | Date: | Fri, 01 Jul 2022 19:37:31 +0000 |
| Subject: | note 78597 deleted from function.preg-replace by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218840@lists.php.net to get a copy of this message | ||
Note Submitter: mike dot hayward at mikeyskona dot co dot uk
----
Hi.
Not sure if this will be a great help to anyone out there, but thought i'd post just in case.
I was having an Issue with a project that relied on $_SERVER['REQUEST_URI']. Obviously
this wasn't working on IIS.
(i am using mod_rewrite in apache to call up pages from a database and IIS doesn't set
REQUEST_URI). So i knocked up this simple little preg_replace to use the query string set by IIS
when redirecting to a PHP error page.
<?php
//My little IIS hack :)
if(!isset($_SERVER['REQUEST_URI'])){
$_SERVER['REQUEST_URI'] = preg_replace( '/404;([a-zA-Z]+:\/\/)(.*?)\//i',
"/" , $_SERVER['QUERY_STRING'] );
}
?>
Hope this helps someone else out there trying to do the same thing :)