问题
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