【问题标题】:Error 404 for some values of get parameters某些获取参数值的错误 404
【发布时间】:2015-05-18 19:26:17
【问题描述】:

我正在使用以下脚本之一开发一个网站:

http://localhost/query.php?lat=1.361109&lng=103.828969&rad=2 [404]

我收到此 URL 的 404 Not found 错误,同时对于其中一个参数的值略有不同,脚本可访问并正在执行。例如

http://localhost/query.php?lat=1.361119&lng=103.828969&rad=2  [Working fine]

我在 Windows 上使用 Apache 2.4。谁能指出这可能是什么原因?我没有在我的项目中的任何地方使用.htaccess

【问题讨论】:

    标签: apache url


    【解决方案1】:

    可能服务器端代码检查数据并在某些情况下返回 404,如下所示:

    HttpResponseMessage<Book> GetBook(int id)
    {
    HttpResponseMessage<Book> result;
    var book  = _repo.GetBook(id);
    if (book != null)
    {
        result = new HttpResponseMessage<Book>(book);
    }
    else
    {
      // 404 error 
        result = new HttpResponseMessage<Book>(HttpStatusCode.NotFound);
    }
    return result;
    

    }

    【讨论】:

    • 我没有在问题中提到它,但我使用的是 PHP。我根本没有重定向到任何 404 页面。
    • 您是否正在检查来自 Get 请求的输入?
    猜你喜欢
    • 2012-08-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-16
    • 2016-06-05
    • 2019-09-09
    • 2021-10-05
    相关资源
    最近更新 更多