1

我正在使用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_module, mod_rewrite.so, rewrite,mod_rewrite .

然后,当我重新启动服务器时,我只得到这个日志,但是当我尝试转到localhost/mysite.

[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.

更新
这是有关我的文件夹结构的更多信息。我已经把我的 DirectoryRootD:/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
4

2 回答 2

3

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

尝试

LogLevel alert rewrite:trace3

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

文档

添加附加信息后添加

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

我可以建议您在 WAMPServer 论坛上查看此文档 Wampserver 2.4 安装后要做什么

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

LogLevel warn rewrite:trace8

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

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

错误:

#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>
于 2013-10-14T08:34:05.057 回答
0

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

LogLevel alert rewrite:trace3

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

于 2014-08-13T11:11:36.057 回答