title: How to make Canonicals with PHP
body: <p>I've search around on SO, but can't find an exact answer to my needs.</p>
  
  <p>Generating a URL is pretty easy... </p>
  
  <p>Like so:</p>
  
  <pre><code>&lt;link rel="canonical" href="https://example.com&lt;?php echo ($_SERVER['REQUEST_URI']); ?&gt;" /&gt;
  </code></pre>
  
  <p>But, the issue with this is, the <code>$_SERVER['REQUEST_URI'])</code> will always fetch the current file in use, so the canonical URL could potentially change.</p>
  
  <p>So it could flick between www.example.com/hello.php and www.example.com/hello/, and many other variations depending on how the user accesses your site.</p>
  
  <p>How do I make it so it's always the same url? (preferably without .php)</p>