Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.wtal.de!news.tal.de!fu-berlin.de!uni-berlin.de!not-for-mail From: "M. Strobel" Newsgroups: comp.lang.php Subject: Re: Apache and php to show http request headers. Date: Mon, 25 Jun 2012 21:36:15 +0200 Lines: 119 Message-ID: References: <041d6312-2dee-4535-8215-6e9dbcb1e274@z19g2000vbe.googlegroups.com> <%t1Gr.28393$Bp1.24038@newsfe10.iad> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de mQmwc9i8IPAYrjtLmZEYwAtQP5wUmmWmupLJdZyDJ59iCg22V/sa7wobvb1k8I1k4= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120601 Thunderbird/13.0 In-Reply-To: Xref: csiph.com comp.lang.php:6437 Am 25.06.2012 20:22, schrieb Daniel Pitts: > On 6/25/12 11:00 AM, The Natural Philosopher wrote: >> Daniel Pitts wrote: >>> On 6/25/12 10:17 AM, M. Strobel wrote: >>>> Am 25.06.2012 18:48, schrieb Jerry Stuckle: >>>>> On 6/25/2012 12:10 PM, M. Strobel wrote: >>>>>> Am 25.06.2012 16:44, schrieb Jerry Stuckle: >>>>>>> On 6/25/2012 10:42 AM, Tony Mountifield wrote: >>>>>>>> In article , >>>>>>>> Jerry Stuckle wrote: >>>>>>>>> On 6/25/2012 9:36 AM, Tony Mountifield wrote: >>>>>>>>>> In article , Luuk >>>>>>>>>> wrote: >>>>>>>>>>> On 25-06-2012 12:15, brumik wrote: >>>>>>>>>>>> >>>>>>>>>>>> I need to test various http requests from an application and >>>>>>>>>>>> am using >>>>>>>>>>>> Apache/PHP on ubuntu to display the http request headers. The >>>>>>>>>>>> application proxy forwards http requests to the apache >>>>>>>>>>>> server's IP >>>>>>>>>>>> address like as follows: >>>>>>>>>>>> >>>>>>>>>>>> 192.168.40.1/test/test.html >>>>>>>>>>>> >>>>>>>>>>>> where 192.168.40.1 is the apache server. >>>>>>>>>>>> >>>>>>>>>>>> I have a php script to dump the headers as follows: >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> foreach($_SERVER as $h=>$v) >>>>>>>>>>>> #if(ereg('HTTP_(.+)',$h,$hp)) >>>>>>>>>>>> echo "
  • $h = $v
  • \n"; >>>>>>>>>>>> header('Content-type: text/html'); >>>>>>>>>>>> ?> >>>>>>>>>>>> >>>>>>>>>>>> The problem is that to show the headers, I redirect >>>>>>>>>>>> 192.168.40.1/* to >>>>>>>>>>>> the above index.php page using the following redirect: >>>>>>>>>>>> >>>>>>>>>>>> Options +FollowSymlinks >>>>>>>>>>>> RewriteEngine on >>>>>>>>>>>> RewriteCond %{REQUEST_URI} !/index.php$ >>>>>>>>>>>> >>>>>>>>>>>> RewriteRule $ /index.php [R=302,L] >>>>>>>>>>>> >>>>>>>>>>>> However the php request headers page always shows the URI as / >>>>>>>>>>>> index.php as opposed to the 'original' URI requested (/test/ >>>>>>>>>>>> test.html). >>>>>>>>>>>> >>>>>>>>>>>> How can I get it to show the 'original' URI requested? is this >>>>>>>>>>>> something that can be done in PHP or is it apache specific? >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Its apache, because it is redirecting, so PHP does only know >>>>>>>>>>> about the >>>>>>>>>>> redirected request, and does have no knowledge of how this >>>>>>>>>>> request >>>>>>>>>>> reached PHP. >>>>>>>>>> >>>>>>>>>> You could try the Proxy flag in the RewriteRule: >>>>>>>>>> >>>>>>>>>> RewriteRule $ http://localhost/index.php [P,L] >>>>>>>>> >>>>>>>>> He can try a lot of things which won't work. >>>>>>>> >>>>>>>> Well, yes, but I didn't think my suggestion was one of them. If you >>>>>>>> think it is, I would like to know why, so that I would know for the >>>>>>>> future, rather than just be the target of a bit of sarcasm. You >>>>>>>> could >>>>>>>> try something like "That won't work because...." (if applicable). >>>>>>>> >>>>>>>> The OP's original rule obviously wouldn't work, because it tells the >>>>>>>> client browser to generate a completely fresh request with the new >>>>>>>> location. In contrast, the Proxy flag in RewriteRule is supposed to >>>>>>>> make Apache proxy the original request to the new location (even to >>>>>>>> itself if necessary). So the request's original headers should still >>>>>>>> be present, with perhaps one or more proxy headers. >>>>>>>> >>>>>>>> Cheers >>>>>>>> Tony >>>>>>>> >>>>>>> >>>>>>> It's off topic in this newsgroup. If you want to know why, try an >>>>>>> appropriate >>>>>>> newsgroup. >>>>>>> >>>>>> >>>>>> Truth is never off topic. >>>>>> >>>>>> /Str. >>>>>> >>>>> >>>>> Only in your small mind. This is a PHP group - hence the "PHP" in >>>>> its name. There >>>>> are other groups where experts in that area hang out. >>>>> >>>>> And your comment shows why there are so many crappy answers to >>>>> off-topic questions in >>>>> this newsgroup. >>>>> >>>> Ah, small mind. What could PHP do without Apache servers? >>> Quite a bit. Apache isn't a requirement for PHP by any means. >>> >>> >> No but then neither is a road for a car, nevertheless I wouldn't >> normally consider using a car off road ... > Straw man; the car/road analogy is lacking. There are *other* web servers than > Apache, such as nginx for example. Yes, there are. Nginx usage is in the one percent range according to http://phpadvent.org/2010/usage-statistics-by-ilia-alshanetsky I would consider nginx here quite off topic. /Str.