开发者

How do I determine if a PHP script I'm running is as a result of mod_rewrite pointing to it?

开发者 https://www.devze.com 2023-01-06 03:26 出处:网络
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.

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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消