<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

      <title>Comments on: PHP predefined variables and URLs</title>
      <link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs/</link>
      <description>Comments on Ask MetaFilter post PHP predefined variables and URLs</description>
	  	  <pubDate>Wed, 14 Nov 2007 05:57:55 -0800</pubDate>
      <lastBuildDate>Wed, 14 Nov 2007 05:57:55 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: PHP predefined variables and URLs</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs</link>	
  	<description>I&apos;m developing a custom 404 page using .htaccess to redirect to the 404.html.  I&apos;m trying to use PHP (via an include in the 404.html) to show the referring page (using $_SERVER[&apos;HTTP_REFERER&apos;]).  This works fine.   I&apos;d also like to return the bad URL that originates the 404.  Is this possible using PHP? &lt;br /&gt;&lt;br /&gt; I&apos;ve reviewed the documentation at php.net regarding predefined variables but I&apos;m not seeing what I want.  If it&apos;s not possible via PHP is it possible using any other technology?   If so, any suggestions?  I do not have access to the server configuration BTW.&lt;br&gt;
&lt;br&gt;
Thanks.</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2007:site.76215</guid>
  	<pubDate>Wed, 14 Nov 2007 05:10:07 -0800</pubDate>
  	<dc:creator>lyam</dc:creator>
	
	<category>php</category>
	
	<category>htaccess</category>
	
	<category>404</category>
	
	<category>web</category>
	
	<category>development</category>
	
	<category>resolved</category>
	
</item>
<item>
  	<title>By: malevolent</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs#1132642</link>	
  	<description>On most servers you can use $_SERVER[&apos;REQUEST_URI&apos;] to get the current page&apos;s URL relative to root, or use something like &lt;a href=&quot;http://www.webcheatsheet.com/PHP/get_current_page_url.php&quot;&gt;this&lt;/a&gt; to build the full URL. Whatever you use, make sure it&apos;s HTML-encoded before being displayed to avoid any potential XSS nastiness.&lt;br&gt;
(I assume you&apos;re not actually doing an HTTP redirect, just rewriting the URL to point to 404.html internally? Otherwise the current page would be 404.html and the referer would be the page originating the error)</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.76215-1132642</guid>
  	<pubDate>Wed, 14 Nov 2007 05:57:55 -0800</pubDate>
  	<dc:creator>malevolent</dc:creator>
</item>
<item>
  	<title>By: lyam</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs#1132651</link>	
  	<description>Well that explains why REQUEST_URI wasn&apos;t giving me the results I was after.  Thanks for the heads up.  I guess I need to be using mod_rewrite to to internally redirect?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.76215-1132651</guid>
  	<pubDate>Wed, 14 Nov 2007 06:08:31 -0800</pubDate>
  	<dc:creator>lyam</dc:creator>
</item>
<item>
  	<title>By: malevolent</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs#1132775</link>	
  	<description>If you define the 404 in htaccess with something like&lt;br&gt;
ErrorDocument 404 /_errors/404.php&lt;br&gt;
then the URL won&apos;t change and REQUEST_URI will be intact within 404.php</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.76215-1132775</guid>
  	<pubDate>Wed, 14 Nov 2007 08:16:25 -0800</pubDate>
  	<dc:creator>malevolent</dc:creator>
</item>
<item>
  	<title>By: lyam</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs#1132832</link>	
  	<description>I&apos;ve attempted exactly that.  What happens is that when I use relative paths, I get the path name output to the screen.  When I use an absolute path it works, however the URL does change to the 404.htm.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.76215-1132832</guid>
  	<pubDate>Wed, 14 Nov 2007 08:53:29 -0800</pubDate>
  	<dc:creator>lyam</dc:creator>
</item>
<item>
  	<title>By: malevolent</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs#1132984</link>	
  	<description>On my servers (local OS X MAMP and remote Linux), if I use something like&lt;br&gt;
ErrorDocument 404 _errors/404.php&lt;br&gt;
then yes, it just outputs the path, but if I add the slash at the start to specify a path relative to root then it works fine. As you&apos;ve found, specifying a full URL results in a redirect.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.76215-1132984</guid>
  	<pubDate>Wed, 14 Nov 2007 10:07:53 -0800</pubDate>
  	<dc:creator>malevolent</dc:creator>
</item>
<item>
  	<title>By: lyam</title>
  	<link>http://ask.metafilter.com/76215/PHP-predefined-variables-and-URLs#1133003</link>	
  	<description>Wow, I swear I tried that as well, but I must&apos;ve been mistaken.  All is well now.  Thanks!</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.76215-1133003</guid>
  	<pubDate>Wed, 14 Nov 2007 10:18:11 -0800</pubDate>
  	<dc:creator>lyam</dc:creator>
</item>

    </channel>
</rss>
