title: Run PHP code from .htaccess?
body: <p>Say I have a rewrite that needs to pass the url to a PHP function and retrieve a value in order to tell what the new destination should be?  is there a way to do that?</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Thanks so far guys..I am still having trouble but i'll show you my code:</p>
  
  <p>.htaccess</p>
  
  <pre><code>#I got the file path by echoing DOCUMENT_ROOT and added the rest.
  RewriteMap fixurl prg:/var/www/vhosts/mydomain.com/httpsdocs/domain_prototype/code_base/url_handler.php
  
  RewriteEngine On
  RewriteRule (.*) ${fixurl:$1} [PT]
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>set_time_limit(0); # forever program!
  $keyboard = fopen("php://stdin","r");
  while (1) {
          $line = trim(fgets($keyboard));
          print "www.google.com\n";  # &lt;-- just test to see if working.
  }
  </code></pre>
  
  <p>However I am getting a <strong>500 Internal Server Error</strong> I am not sure if there is an error in my .htaccess or in my PHP?</p>