【问题标题】:How can I see the value of RewriteRule or RewriteCond server variables?如何查看 RewriteRule 或 RewriteCond 服务器变量的值?
【发布时间】:2012-12-18 14:37:47
【问题描述】:

例如,如果我想查看 php 中某个变量的值,我会这样做:

$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

但是当我写一些mod_rewrite规则时,现在我只能猜测RewriteRule的值是什么,重写($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?

有什么方法可以打印或以某种方式查看每行之后我得到什么值?例如,我想看看RewriteRule ^(.+)$ $0 [NC, L] 中有什么,^(.+)$ 中有什么,然后$0 中有什么。

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    不,不是你问的方式。

    错误日志是一个很好的帮助。将 LogLevel 设置为调试,如下所示:httpd.conf 文件中的LogLevel debug

    如果使用 Firefox,您可以尝试livehttpheaders,例如,查看标题和其他相关信息。其他浏览器也有等效的扩展。

    不用说,一个带有echo var_dump($_SERVER);或类似语句的映射地址的php脚本将显示结果的完整信息。

    【讨论】:

      猜你喜欢
      • 2014-10-18
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      相关资源
      最近更新 更多