title: PHP & Hash / Fragment Portion of URL
body: <p>I am trying to find a way to save the hash portion of a url and as a PHP variable.  This idea is a bit kooky, but bear with me...</p>
  
  <p>I'd like to extract the "location" fragment from the following URL and save it as a PHP variable.</p>
  
  <pre><code>http://www.example.com/#location
  </code></pre>
  
  <p>However, discussion at this <a href="https://stackoverflow.com/questions/940905/can-php-read-the-hash-portion-of-the-url">link</a> indicates that the fragment of a URL is only reachable through JavaScript.</p>
  
  <p>But would it be possible to create a link where the fragment is duplicated in the URL, parsed by PHP, and then removed by mod rewrite? So....</p>
  
  <p>Original url:</p>
  
  <pre><code>http://www.example.com/location/#location
  </code></pre>
  
  <p>PHP gets location variable thanks to the plain "location" in the URL</p>
  
  <p>Apache then rewrites the link to:</p>
  
  <pre><code>http://www.example.com/#location
  </code></pre>
  
  <p>I'm curious to know if there is an elegant way to solve this problem.</p>