title: How do I keep my REST API address in the browser address bar but call a different PHP page?
body: <p>I have a PHP page that displays product details by passing in the product code like this:</p>
  
  <p>mywebsite/product.php?id=1234</p>
  
  <p>This has all the HTML to generate the page in question, with a small amount of PHP and some Javascript that makes an AJAX call to get the product details.</p>
  
  <p>I have also written as REST API using Silex / PHP that the Javascript calls to get the product info from my database, which looks like this:</p>
  
  <pre><code>&lt;?php
  session_start();
  require_once __DIR__.'/vendor/autoload.php';    
  
  $app = new Silex\Application();
  $app['debug'] = true;
  
  
  $app-&gt;get('/product/{productId}', function($productId) use($app) { 
  
      $result = getProductDetails($productId);    
      return json_encode($result, JSON_NUMERIC_CHECK);
  }); 
  
  $app-&gt;run();
  
  ?&gt;
  </code></pre>
  
  <p>(function getProductDetails is in another PHP file that is included)</p>
  
  <p>However, I want to convert the main page to a REST API that looks something like this:</p>
  
  <p>mywebsite/product/1234</p>
  
  <p>I've tried including the product.php page, but that doesn't really work at all. I've also tried redirecting like this:</p>
  
  <pre><code>$app-&gt;get('/product/{productid}', function($productid) use($app) { 
  
      Header('Location: /product.php?id='.$productid);
      die();
  }); 
  </code></pre>
  
  <p>but then the product.php?id= appears in the address bar.</p>
  
  <p>Can anyone please point me in the right direction, so that I can type:
  mywebsite/product/1234
  and that's what the browser show, but that I can use a page defined in a different PHP file ?</p>