标签: http-status-code-404

Nginx 返回 200 而不提供文件

我写了这个/etc/nginx/conf.d/apply.conf并启动了nginx。

server {
  location = /hoge {
    return 200;
  }
}
Run Code Online (Sandbox Code Playgroud)

但curl命令失败。

curl localhost:80/hoge
Run Code Online (Sandbox Code Playgroud)

它说

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.13.9</center>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

日志是

open() "/usr/share/nginx/html/hoge" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /hoge HTTP/1.1", host: "localhost"
Run Code Online (Sandbox Code Playgroud)

我只想返回没有响应正文或响应正文为空白的状态代码。

我改成这个但仍然不起作用。

location /hoge {
return 200 'Wow';
add_header Content-Type text/plain;
}
Run Code Online (Sandbox Code Playgroud)

也尝试过这个。

location /hoge {
return 200 'Wow';
default_type text/plain;
}
Run Code Online (Sandbox Code Playgroud)

http nginx http-status-code-404 nginx-location nginx-status

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

WP 图像未通过 HTTPS 显示

我遇到了一个奇怪的 SSL 问题,事实上我的所有图像都没有显示在 SSL 上,这是一个例子:

HTTP: http: //www.electronique-mixte.fr/wp-content/uploads/2017/06/numidea-logo-electronique-mixte.png

HTTPS: https: //www.electronique-mixte.fr/wp-content/uploads/2017/06/numidea-logo-electronique-mixte.png

对于同一张图片,HTTP 有效,但 HTTPS 无效!

任何想法 ?

网站 :

HTTPS 未显示图片

HTTPS图片404错误:

在此输入图像描述

HTTP 工作正常:

在此输入图像描述

另一个浏览器(Edge):

在此输入图像描述 PS:我正在使用隐身选项卡(避免缓存)

wordpress https image http http-status-code-404

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

使用节点和角度应用程序刷新页面时获取 404 页面

我是新来的Angular。我尝试使用Nodejs和创建 CRUD 操作Angular。我正在使用NodejsandExpress作为后端和Angular前端。

当我使用 routerLink 在页面上导航时,它工作正常,但是当我在页面上导航然后刷新页面时,它会显示页面未找到错误。

我知道那里发生了什么,Express 应用程序中没有定义路线,所以我刷新页面,它显示 404 错误。

如何使其与 Angular 和 Express 路线配合使用?

这是我的代码。

app.js( 服务器 )

const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');
var app = express();


app.use(bodyParser.urlencoded({extended : false}));
app.use(bodyParser.json());

app.use(express.static(path.join(__dirname,'dist/MEAN-blog')));


app.get('/',(req,res) =>{
    res.sendFile(path.join(__dirname,'dist/MEAN-blog/index.html'));
});

app.post('/register',(req,res) =>{
    var u = new User(req.body);
    u.save();
    res.send(u).status(200);
})


var server  = http.createServer(app);

server.listen(8080,'0.0.0.0',() =>{
    console.log('Server is running …
Run Code Online (Sandbox Code Playgroud)

javascript node.js http-status-code-404 angular-ui-router angular

3
推荐指数
1
解决办法
2723
查看次数

ASP.NET Core / Kestrel 无法一致地提供静态内容

背景信息:

  • ASP.NET Core v3.1 带 RazorPages
  • 在本地运行良好(本地主机上的 Win10 和 Kestrel)
  • 在部署到 Linux VM (Ubuntu 18) 时, wwwroot/ 中的文件返回 404 ,Bootstrap 在本地工作正常,没有 404
  • 发布方式dotnet publish -r linux-x64
  • 部署的应用程序正在运行 Kestrel 并转发来自 NGINX 的请求。

启动.cs

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    /// Included before other middleware (needed due to nginx forwarding)
    /// Per: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-3.1
    app.UseForwardedHeaders(new ForwardedHeadersOptions
    {
        ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
    });

    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Error");
        app.UseHsts();
    }

    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseRouting();

    app.UseCookiePolicy(); // -- Added …
Run Code Online (Sandbox Code Playgroud)

http-status-code-404 razor twitter-bootstrap kestrel-http-server asp.net-core

3
推荐指数
1
解决办法
1513
查看次数

Django 404错误页面未找到...当前路径与最后一个路径匹配

我是 django 的新手,我正在尝试我自己的民意调查教程的变体。我的应用程序运行良好,每个页面都正确加载。然后我做了一个改变;我创建然后删除了一个模型。现在,许多网址似乎已损坏。我不明白这个错误:

\n
Page not found (404)\nRequest Method: GET\nRequest URL:    http://127.0.0.1:8000/polls/1/pick/\nRaised by:  polls.views.pick\nUsing the URLconf defined in mySite.urls, Django tried these URL patterns, in this order:\n\npolls/ [name='index']\npolls/ <int:pk>/ [name='detail']\npolls/ <int:pk>/results/ [name='results']\npolls/ <int:question_id>/vote/ [name='vote']\npolls/ <int:question_id>/tally/ [name='tally']\npolls/ <int:question_id>/pick/ [name='pick']\nThe current path, polls/1/pick/, matched the last one.\n\nYou\xe2\x80\x99re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.\n
Run Code Online (Sandbox Code Playgroud)\n

所以我不明白为什么它说:当前路径 polls/1/pick/ 与最后一个匹配。

\n

并且还找不到页面?这是如何运作的?当应用程序以前运行良好时,可能是什么导致了这种情况?

\n

我的网址.py: …

django http-status-code-404

3
推荐指数
1
解决办法
5403
查看次数

Next.js - 如何隐藏 404 页面上的导航和页脚组件?

import Footer from "./Footer";
import Navigation from "./Navigation";
import { useRouter } from "next/router";

function Layout({ children }) {
  const router = useRouter();
  return (
    <>
      {router.pathname !== "/*" && <Navigation />}
      {/* {router.pathname !== "*" && <Navigation />} */}
      <main className="main-content">{children}</main>
      {router.pathname !== "/*" && <Footer />}
      {/* {router.pathname !== "*" && <Footer />} */}
    </>
  );
}

export default Layout;
Run Code Online (Sandbox Code Playgroud)

不幸的是,带有星号的方法不起作用:/?!?

预先感谢您并向大家致以最诚挚的问候;-)

javascript http-status-code-404 next.js

3
推荐指数
1
解决办法
3073
查看次数

Flutter网页刷新出现404 Not Found错误

在主要方法中,我使用了 UrlStrategy 包,如下所示,因为我不想在我的网址中包含 #:

void main() {
  setPathUrlStrategy();
  runApp(const MyApp());
}
Run Code Online (Sandbox Code Playgroud)

我在调试模式下测试网站时,没有问题。然后我发布了我的网站。主页就像www.example.com,当我尝试用F5刷新页面时,没有问题。然后我导航到另一个页面,例如www.example.com/about-us并尝试再次使用 F5 刷新页面,但出现“404 not found”错误。

为了解决这个问题,我在 htdocs 中创建了 .htaccess 文件并在该文件中写入:

RewriteEngine on
RewritwCond %{REQUEST_FILENAME} !-d
RewritwCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.html [L]
Run Code Online (Sandbox Code Playgroud)

但我开始收到 500 内部服务器错误。

htdocs 之外存在一个现有的 .htaccess 文件。我复制了上面的代码并将其粘贴到现有的 .htaccess 中。但又出现同样的问题。现有.htaccess文件中的代码如下:

##################################################
#
# DO NOT EDIT THIS FILE
#
# Create a new .htaccess file in your htdocs
# directory (or example.com/htdocs/ directory)
# to add your own rules or override these rules.
# …
Run Code Online (Sandbox Code Playgroud)

routes refresh http-status-code-404 flutter

3
推荐指数
1
解决办法
4697
查看次数

如何从HttpModule生成404错误?

我有一个ASP.NET HttpModule,它处理HttpApplication.BeginRequest以将一些请求重定向到其他文件.通常,我会做一些事情,比如解析请求,将文件写入HttpContext.Current.Response.OutputStream,然后调用HttpApplication.CompleteRequest().对于某些请求,我找不到相关文件 - 如何返回404错误?

asp.net http-status-code-404

2
推荐指数
1
解决办法
1823
查看次数

用自定义图像替换破碎的外部图像

我正在遍历在外部站点托管的一系列URL图像字符串.

它看起来像这样:

def get_image_urls
  image_url_array.each do |image_url|
    puts image_tag image_url
  end
end
Run Code Online (Sandbox Code Playgroud)

这将返回外部网站上托管的图像的URL.问题是,其中一些图像可能会被破坏(404).例如:

get_image_urls
# These would return image_tags, but for brevity...
=> "http://someothersite.com/images/1.jpg"
   "http://someothersite.com/images/2.jpg"
   "http://someothersite.com/images/3.jpg" # <-- (Broken: 404)
   "http://someothersite.com/images/4.jpg"
   "http://someothersite.com/images/5.jpg" # <-- (Broken: 404)
Run Code Online (Sandbox Code Playgroud)

我要做的是将损坏图像的URL字符串替换为我自己网站上托管的"缺失"图像.所以使用上面的例子,3.jpg和5.jpg被打破了,我想要返回这样的东西:

get_image_urls
# These would return image_tags, but for brevity...
=> "http://someothersite.com/images/1.jpg"
   "http://someothersite.com/images/2.jpg"
   "http://mysite.com/images/missing.png"
   "http://someothersite.com/images/4.jpg"
   "http://mysite.com/images/missing.png"
Run Code Online (Sandbox Code Playgroud)

有没有一种简单的方法可以解决这个问题?非常感谢提前.

ruby ruby-on-rails image http http-status-code-404

2
推荐指数
1
解决办法
1997
查看次数

AJAX Webmethod调用在MVC3上返回404

我一直在使用EXTJS 4并在.aspx页面的代码隐藏处通过AJAX调用加载我的商店到Webmethod.这个方法适用于我的所有项目,直到我尝试将EXTJS 4工作移植到MVC3项目中.我的电话现在正在返回404.

关键部分是项目(和EXTJS4 webmethod调用)在我的同事的机器上运行 - 只有我的机器受到'404'错误的影响.任何Webmethod调用,无论是他们的一个或由我编写,都会返回"未找到资源".这是怎么回事?

一些代码如果有帮助:加载商店:

Ext.define('pr.store.Store-Items', {
    extend: 'Ext.data.Store',
    model: 'pr.model.Model-Items',
    pageSize: 200,
    groupField: 'groupID',
    autoLoad: { params: { start: 0, limit: 200 } },
    proxy: {
        type: 'ajax',
        //get data from json file for now
        headers: { 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Content-Type': 'application/json; charset=utf-8' },
        url: '/Project/Data.ashx/GetData',           
        reader: {
            type: 'json',
            root: 'd.objects',
            totalProperty: 'd.totalCount'
        },
        extraParams: {
            where: Ext.encode(new Array(''))
            , difference: true
            , mode: 0
        }
    }
});
Run Code Online (Sandbox Code Playgroud)

的WebMethod

 [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json, UseHttpGet=true)] …
Run Code Online (Sandbox Code Playgroud)

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

2
推荐指数
1
解决办法
3466
查看次数