How can I see the value of RewriteRule or RewriteCond server variables?

ⅰ亾dé卋堺 提交于 2019-12-12 03:44:59

问题


For example, if I want to see what value is in some variable in php I do this:

$foo = 'This is a variable foo';

var_dump($foo);  // string(22) "This is a variable foo"
echo $foo;       // This is a variable foo
print_r $foo;    // This is a variable foo

But when I write some mod_rewrite rules, for now I can only guess what value comes to the RewriteRule and what it becomes after rewriting ($0):

<Directory /public>
    DirectoryIndex index.php
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]   // what is %{REQUEST_FILENAME}
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ $0 [NC, L]             // what is ^(.+)$, and what is $0?

Is there any way to print or somehow to see what value I get after each line? For example, I'd like to see what comes in RewriteRule ^(.+)$ $0 [NC, L], what is in ^(.+)$ and what is then in $0.


回答1:


No, there isn't the way you ask.

The error log is a good help. Set LogLevel to debug, like this: LogLevel debug in the httpd.conf file.

If using Firefox, you can try livehttpheaders, for example, to watch the headers and other relevant information. There are equivalent extensions for other browsers.

Needless to say, a php script at the mapped address with echo var_dump($_SERVER); or similar statement, will display a complete information of the result.



来源:https://stackoverflow.com/questions/13927208/how-can-i-see-the-value-of-rewriterule-or-rewritecond-server-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!