title: Page re-routing based on URL before the page loads
body: <p>What I am trying to do is make a system where users can type basic information into the address bar in the form of directories</p>
  
  <p>i.e:</p>
  
  <pre><code>domainname.com/country/state/city/
  </code></pre>
  
  <p>and then be "re-routed" to specific information on a universal page with URL variables</p>
  
  <p>i.e:</p>
  
  <pre><code>domainname.com/Canada/BritishColumbia/Squamish  =&gt;  domainname.com/wall.php?country=canada&amp;state=britishcolumbia&amp;city=squamish
  </code></pre>
  
  <p>I know this could be accomplished by creating actual directories for each city that has been registered and then having an index.php inside that directory with a 301 redirect but that seems like a super-inefficient, messy last resort.</p>
  
  <p>How can I parse the URL before the page loads and then redirect to wall.php with the specific URL variables? I can't seem to find any tutorials or anything else relevant.</p>