【问题标题】:Wampserver loglevel rewrite not workingWampserver 日志级别重写不起作用
【发布时间】:2013-10-20 14:07:08
【问题描述】:

我正在使用WampServer,我想从 .htaccess 中调试我的重写规则,因为我仍然收到 404 错误。

我已经启用了 rewrite_module、log_debug_module、log_forensic_module 和 log_config_module,但是在我的错误日志中我没有收到任何关于 .htaccess 的信息。

在 httpd.conf 中,我将LogLevel更改为:LogLevel warn mod_rewrite.c:trace8。我还尝试了以下选项:rewrite_modulemod_rewrite.sorewritemod_rewrite

然后,当我重新启动服务器时,我只收到此日志,但当我尝试转到 localhost/mysite 时,我没有收到任何有关 Web 请求的信息。

[Sat Oct 12 17:33:07.063441 2013] [mpm_winnt:notice] [pid 8884:tid 412] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Oct 12 17:33:09.063556 2013] [mpm_winnt:notice] [pid 1632:tid 288] AH00364: Child: All worker threads have exited.
[Sat Oct 12 17:33:09.078557 2013] [mpm_winnt:notice] [pid 8884:tid 412] AH00430: Parent: Child process 1632 exited successfully.
[Sat Oct 12 17:33:48.859832 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00455: Apache/2.4.4 (Win64) PHP/5.4.12 configured -- resuming normal operations
[Sat Oct 12 17:33:48.859832 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00456: Server built: Feb 22 2013 22:08:37
[Sat Oct 12 17:33:48.859832 2013] [core:notice] [pid 8252:tid 412] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.4\\bin\\httpd.exe -d C:/wamp/bin/apache/Apache2.4.4'
[Sat Oct 12 17:33:48.867833 2013] [mpm_winnt:notice] [pid 8252:tid 412] AH00418: Parent: Created child process 6216
[Sat Oct 12 17:33:49.145848 2013] [mpm_winnt:notice] [pid 6216:tid 288] AH00354: Child: Starting 150 worker threads.

更新
这是有关我的文件夹结构的更多信息。我已将我的 DirectoryRoot 放入 D:/www,而我的 .htaccess 文件位于 D:/www/mysite

httpd.conf 中的一些部分:

<Directory />
    AllowOverride none
    Require all granted
</Directory>

DocumentRoot "D:/www"
<Directory "D:/wamp/www">
    Options Indexes FollowSymLinks
    AllowOverride All

#    Require all granted
#   onlineoffline tag - don't remove
     Order Deny,Allow
     Deny from all
     Allow from 127.0.0.1
     Allow from ::1
     Allow from localhost
</Directory>

#ErrorLog "logs/error.log"
ErrorLog "c:/wamp/logs/apache_error.log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn rewrite:trace3

禁用重写模块会在RewriteEngine 上出现错误,所以我想它确实找到了我的 .htaccess 文件。

这是我的 .htaccess 文件:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)/?$ index.php/$1

【问题讨论】:

    标签: .htaccess mod-rewrite wampserver


    【解决方案1】:

    编辑你的“httpd.conf”日志后

    LogLevel alert rewrite:trace3
    

    您应该重新启动 apache 服务器以应用更改。

    【讨论】:

      【解决方案2】:

      可能是您使用的是Apache 2.4.x,如果是这样,他们在日志记录领域进行了重大更改。

      试试

      LogLevel alert rewrite:trace3
      

      另一个变化是记录的信息被写入正常的error_log文件。

      Documentation

      在添加附加信息后添加

      您的 httpd.conf 文件中有一些相当明显的错误。

      我可以建议您在 WAMPServer 论坛Wampserver 2.4 What to do after Installing 上查看此文档

      我刚刚更改了我的 WAMPServer Apache conf:

      LogLevel warn rewrite:trace8
      

      并且在我的 apache_error.log 中从 rewrite 模块获得了很多额外的行。

      确保您实际上在服务器上运行了将执行 mod_rewrite 和您在 .htaccess 中的 RewriteRule 的东西

      错误:

      #WRONG Allows access to the root of your D: drive and all subfolders, great for hackers
      <Directory />
          AllowOverride none
          Require all granted
      </Directory>
      
      #CORRECTED
      <Directory />
          AllowOverride none
          Require all denied
      </Directory>
      

      .

      #WRONG
      DocumentRoot "D:/www"
      
      #CORRECTED
      DocumentRoot "d:/wamp/www"
      

      .

      #WRONG
      <Directory "D:/wamp/www">
          Options Indexes FollowSymLinks
          AllowOverride All
      
      #    Require all granted
      #   onlineoffline tag - don't remove
           Order Deny,Allow
           Deny from all
           Allow from 127.0.0.1
           Allow from ::1
           Allow from localhost
      </Directory>
      
      
      #CORRECTED
      <Directory "D:/wamp/www">
          Options Indexes FollowSymLinks
          AllowOverride All
      
      #   onlineoffline tag - don't remove
           Require local
      </Directory>
      

      【讨论】:

      • 是的,我也尝试过这种组合,我使用的是 2.4.4。我仍然没有收到任何调试信息。我将使用有关文件夹结构和 httpd.conf 部分的更多信息来更新我的问题。
      • 在我的回答中查看更多信息。
      • 我已尝试进行您告诉我的更改,但似乎不起作用。 Require all denied 没有给我任何权利并返回 403。我也尝试了文档中的更改,但这些似乎也没有帮助。
      • 看了很久才发现我的错误。它说&lt;Directory "D:/wamp/www"&gt; 而不是&lt;Directory "D:/www">
      • 其实这两种情况下都应该写成D:/wamp/www
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多