title: Normalizing uri part given base url, with PHP
body: <p>First of, I'm doing this for a web crawler (aka spider aka worm...)</p>
  
  <p>Given two strings (base url and relative url), I need to determine the absolute url.
  It is especially confusing when it comes to "SEO friendly" crap, such as:</p>
  
  <p>Base url: <a href="http://aaa.com/january/15/test" rel="nofollow noreferrer">http://aaa.com/january/15/test</a>
  Found url: /test.php?aaa</p>
  
  <p>How would I know that the above aren't folders or not?
  Eg; the absolute path would be:</p>
  
  <blockquote>
    <p><a href="http://aaa.com/january/15/test/test.php?aaa" rel="nofollow noreferrer">http://aaa.com/january/15/test/test.php?aaa</a></p>
  </blockquote>
  
  <p>Or:</p>
  
  <blockquote>
    <p><a href="http://aaa.com/january/15/test.php?aaa" rel="nofollow noreferrer">http://aaa.com/january/15/test.php?aaa</a></p>
  </blockquote>
  
  <p>?</p>
  
  <p>The confusion stems from whether there is an index in action or not. "/test/index.php" or "/index.php"?</p>