标签: http-status-code-404

PHP 404错误页面将不显示内容

我在Windows/IIS/PHP webhost上实现自定义404错误页面时遇到问题.每当我尝试在标题中发送404状态消息时,不会向客户端发送任何内容,而是显示空白页面.

这是我正在使用的一个非常简单的脚本:

<?php
  header('HTTP/1.1 404 Not Found');
  header('Status: 404 Not Found');
  var_dump(headers_list());
?>
Run Code Online (Sandbox Code Playgroud)

在我的开发机器上,输出(在浏览器中显示)是

array(2) { [0]=>  string(23) "X-Powered-By: PHP/5.2.6" [1]=>  string(21) "Status: 404 Not Found" }
Run Code Online (Sandbox Code Playgroud)

在我的主机上没有输出.我无法生成除空白页面之外的任何内容,无论PHP回应什么内容,或者作为普通HTML包含在下面,尽管PHP处理例如日志记录,数据库写入等正常继续.

任何人都可以建议问题可能是什么或如何解决它?

php header http-status-code-404

0
推荐指数
1
解决办法
2972
查看次数

自定义404页面发送200状态代码

404错误页面的200 OK标题错误:

服务器响应:
http://www.example.com/err404.html HTTP
状态代码:HTTP/1.1 200 OK

我的客户说,它应该给404.

php http-status-codes http-status-code-404

0
推荐指数
1
解决办法
4720
查看次数

为什么我在每个合法的pagehit后都有404.php的页面命中?

我正在使用Intranet系统,该系统在每个页面上检查用户的cookie,验证他们是否可以根据数据库权限查看当前页面,并记录包含其id和页面URL的页面匹配.

我只是注意到在pagehits表中,我看到每个合法页面命中后一秒钟404.php(我在Apache配置中指定的自定义404页面)的条目.

这可能是我的错,还是与Apache决定如何加载404页面有关?

我正在使用Apache 2.2.14(Win32)和PHP 5.3.2.

php apache2 http-status-code-404

0
推荐指数
2
解决办法
86
查看次数

PHP当数据库中不存在记录时该怎么做

我正在查询数据库中是否存在与url段中传递的id匹配的单个记录www.site.com/post/24.

假设帖子24不存在.什么是安全和seo兼容的方式来处理未找到的数据库请求?

以下是使用Codeigniter模型的当前解决方案:

    function read_post($post_id) //argument is the value of the url segment
    {
        $user_id = $this->tank_auth->get_user_id();

        $this->db->where('user_id', $user_id);
        $this->db->where('post_id', $post_id);
        $this->db->limit(1);
        $query = $this->db->get('posts');

        //check if record exists
        if ($query->num_rows() > 0) //row is returned
        {
            return $query->row(); //passed to controller and view
        }
        else
        {
            show_404(); //generate 404 message
            return FALSE; //------------------------or exit()?
        }
    }
Run Code Online (Sandbox Code Playgroud)

请分享您自己最好的方法/意见.

php mysql codeigniter http-status-code-404

0
推荐指数
1
解决办法
207
查看次数

ASP.NET MVC 3 AJAX请求返回404 Not Found错误

这是我的代码(下面的问题):

视图

// This function is called by another function when radioButtonGroup.change().
var requestValues = function (form) {
    var option = form.find("input:radio:checked").attr("value");

    // This seemingly shows the correct url for the action method desired.
    alert("Form Action: " + form[0].action + "\nForm Method: " + form[0].method);

    if (form.valid()) {
        $.ajax({
            url: form[0].action,
            type: form[0].method,
            data: option,
            success: function (result) {
                alert("Had success.");
                $('#createForm').replaceWith(result);
            },
            error: function (xhr) {
                alert("An error occurred: " + xhr.status + " " + xhr.statusText);
            }
        }); …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc jquery asp.net-ajax http-status-code-404 asp.net-mvc-3

0
推荐指数
1
解决办法
5015
查看次数

多个扩展上的Magento配置404

我在Magento(/ admin>系统>配置)上的多个扩展中遇到404错误,我通过Magento Connect 2.0安装.我认为这不是扩展的问题,但更多的是我的安装问题.

你有这样的经历吗?

提前致谢

configuration magento http-status-code-404

0
推荐指数
1
解决办法
557
查看次数

找不到对象!在此服务器上找不到请求的URL。本地主机

大家好。我有一个典型的设置A,M,P,我只是在本地服务器上进行一些测试以设置网页。我对php和动态网站有些陌生,所以我有点困惑。所以我在这里陷入僵局。每当我尝试在浏览器中查看页面并单击链接时,都会出现此错误:

找不到对象!在此服务器上找不到请求的URL。推荐页面上的链接似乎有误或已过时。请将该错误告知该页面的作者。如果您认为这是服务器错误,请与网站管理员联系。错误404本地主机Apache / 2.4.3(Win32)OpenSSL / 1.0.1c PHP / 5.4.7

my url looks like this: http://localhost/test/content/home
Run Code Online (Sandbox Code Playgroud)

这是我的index.php页面和nav.php页面的代码

第一个index.php

<?php
include('Config/setup.php');
?>
<?php
if(isset($_GET['page']) && $_GET['page'] == !'') {
    $pg = $_GET['page'];
} else {
    $pg = 'home';
}
#var_dump($pg);
#exit;
?>

<!DOCTYPE HTML>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">

    <title>FTS</title>
    <link href="css/Styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<div class="header temp_Block">
    <?php include('templates/header.php');?>
</div>

<div class="main_nav temp_Block">
    <?php include('templates/main_nav.php');?>
</div>

<div class="main_Content temp_Block">
    <?php include('Content/'.$pg.'.php');?>
</div>

<div class="footer temp_Block">
    <?php include('templates/footer.php');?>
</div>
</body> …
Run Code Online (Sandbox Code Playgroud)

php localhost http-status-code-404

0
推荐指数
1
解决办法
8万
查看次数

错误404:尝试为iOS安装cordova-plugin-zip时的cordova-plugin-file

尝试使用以下方法安装cordoba-plugin-zip时:

cordova plugin add https://github.com/MobileChromeApps/zip.git
Run Code Online (Sandbox Code Playgroud)

记录(https://github.com/MobileChromeApps/cordova-plugin-zip),

我收到以下404错误消息.它尝试引用的cordova-plugin文件是否被移动了?如果是这样,我如何告诉插件在其他地方寻找它?

Installing "cordova-plugin-zip" for ios
Fetching plugin "cordova-plugin-file" via plugin registry
npm http GET http://registry.cordova.io/cordova-plugin-file
npm http 404 http://registry.cordova.io/cordova-plugin-file
Failed to install 'cordova-plugin-zip':Error: 404 Not Found: cordova-plugin-file
Run Code Online (Sandbox Code Playgroud)

registry plugins http-status-code-404 ios cordova

0
推荐指数
1
解决办法
5528
查看次数

SelfHosting ApiController,如何返回错误

我使用这样的例子来创建一个自托管的API控制器.它可以HttpPostHttpGet一个Customer对象.

获得CustomerId 的(简化)函数是:

[RoutePrefix("test")]
public class MyTestController : ApiController
{
    [Route("getcustomer")]
    [HttpGet]
    public Customer GetCustomer(int customerId)
    {    // as a test: react as if this customer exists:
         return new Customer()
         {
              Id = customerId,
              Name = "John Doe",
         };     
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

这很好用.在我的客户端,我可以通过Id向该测试服务器询问客户,并且我获得具有预期数据的客户.

显然,调用函数知道如何将返回的Customer包装到HttpResponseMessage可以传输到我的客户端的对象(?)中.

下一步:如果找不到客户,则返回错误404.

[Route("getcustomer")]
[HttpGet]
public Customer GetCustomer(int customerId)
{    // as a test: only customer 1 exists
     if (customerId == 1)
     {
         return new Customer() …
Run Code Online (Sandbox Code Playgroud)

c# self-hosting http-status-code-404 asp.net-web-api owin

0
推荐指数
1
解决办法
35
查看次数

Laravel - 找不到您要查找的页面

当我点击链接时,我得到了第404页

我不知道哪个部分有问题,有人可以帮帮我吗?

sidenav

<a href="{{ route('posts.indexRequest') }}">Request List</a>
Run Code Online (Sandbox Code Playgroud)

路线

Route::prefix('dashboard')->middleware('role:superadministrator|administrator|editor|author|contributor')->group( function () {
  Route::get('/', 'PagesController@dashboard')->name('dashboard');
  Route::resource('/posts', 'PostController');
  Route::get('/posts/request-list', 'PostController@indexRequest')->name('posts.indexRequest');
});
Run Code Online (Sandbox Code Playgroud)

后控制器

public function indexRequest()
{
  $posts = Post::where('status', 'On Request')->orderBy('created_at')->paginate(12);

  return view('manages.posts.request', compact('posts'));
}
Run Code Online (Sandbox Code Playgroud)

我有这个观点

文件夹结构

php http-status-code-404 laravel

0
推荐指数
1
解决办法
29
查看次数