title: Replace file url with query string php
body: <p>I have 1000 images in my website (running in codeingiter), which are named as</p>
  
  <p><code>My_image_1.png, My_image_2.png ........ My_image_1000.png</code></p>
  
  <p>and available in this url <code>http://example.com/files/My_image_1.png</code></p>
  
  <p>But i want the url is <code>http://example.com/images?cid=1.png</code> = <code>My_image_1.png</code>
  How can i do this in php?</p>
  
  <p>This is what i'm trying</p>
  
  <pre><code>if ( !function_exists('get_img_by_cid')) {
  function get_img_by_cid() {
      if ( isset($_GET['cid']) ) {
          $cid = $_GET['cid'];
          return '/path_to_image/My_image_'.$cid.'.png';
      } else {
          return 'Please specify compound id';
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This function return the original path, but i need url like the example below.</p>
  
  <p>In address bar or img tag wherever i use</p>
  
  <p>Here is an example
  <a href="https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=2244" rel="nofollow noreferrer">https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=2244</a></p>
  
  <p>Any help or tutorial will be greatly appriciated :)</p>