note 78597 modified in function.preg-replace by danbrown

From: Date: Fri, 28 Nov 2008 19:50:39 +0000
Subject: note 78597 modified in function.preg-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147147@lists.php.net to get a copy of this message
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 :) --was-- 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. <? //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 :) If anyone finds a better way, please let met know, I'm still learning ;) http://php.net/manual/en/function.preg-replace.php

« previous php.notes (#147147) next »