views:

42

answers:

1

I have a PHP script and I'd like to know if it's been executed as a result of mod_rewrite redirecting the request to it.

Is there anything I can easily inspect simply to get a yes or no answer? Is there any way to get the rewritten path rather than the one that was originally requested?

A: 

Just do a print_r($_SERVER); and you'll be able to figure out what you need. On my Apache server:

  • Requests redirected through mod_rewrite have a REDIRECT_URL parameter
  • Both REDIRECT_URL and REQUEST_URI point to the originally requested URL
  • Both SCRIPT_NAME and PHP_SELF point to the actual PHP script
casablanca