【问题标题】:mod_rewrite not working - results in 404 error and no logsmod_rewrite 不工作 - 导致 404 错误并且没有日志
【发布时间】:2014-12-08 02:23:21
【问题描述】:

我在我的 Mac 上运行 localhost XAMPP 并尝试使用 mod_rewrite 设置 Apache 服务器,这是我在 .htaccess 中的代码(在 htdocs 中)

<IfModule mod_rewrite.c>

    RewriteEngine On                                        # Turn on the rewriting engine
    RewriteRule ^test/?$ api/rest/v1.0/api_controller.php?request=$1 [NOCASE,LAST]      # Handle requests for “test"

    RewriteLog "logs/rewritelog"
    RewriteLogLevel 7

</IfModule>

这也是.htaccess 文件中唯一的代码。

当我在浏览器中尝试链接 http://localhost/test/1 时,我只是被定向到 404 错误。

我在 htdocs/logs/rewritelog 下检查过,但没有任何文件,甚至没有名为 logs 的文件夹。

更新

我正在运行 Apache 版本 2.4.10

【问题讨论】:

  • 您没有匹配/test/1 的重写规则。也许试试^test/(.*)$
  • 谢谢,但还是没有成功
  • 对为什么没有日志有什么想法吗?
  • 没有重写日志,因为您的 URL /test/1 不匹配任何重写规则。
  • 我尝试通过将“IfModule”重命名为“le”来破坏文件,但发生了同样的错误。我认为我的服务器忽略了.htaccess 文件

标签: php apache .htaccess mod-rewrite


【解决方案1】:

原来.htaccess 文件被保存为.htaccess.txt,其中隐藏了.txt 扩展名。如果遇到同样的错误,请检查 Get Info 中的文件。

【讨论】:

    猜你喜欢
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    • 2019-05-19
    相关资源
    最近更新 更多