标签: http-status-code-404

所有 url 上下文的 404 错误页面

我的 Java Web 应用程序中有一个自定义 404 错误页面。(使用 web.xml 声明)它适用于所有情况。但是,如果 url 模式是这样的:www.mysite.com/admin/cannotfind 自定义错误页面找不到 404 自定义错误页面的图像和 css java 脚本文件。但它适用于像 www.mysite.com/cannotfind 这样的普通 url。任何人都告诉我为什么会出现这种行为。

这是我的错误页面配置

<error-page>
    <error-code>404</error-code>
    <location>/error_pages/error_404.jsp</location>
Run Code Online (Sandbox Code Playgroud)

tx :)

error-handling jsp servlets http-status-code-404

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

Python烧瓶获得404未找到错误

我正在使用Flask设计这个简单的网站.但我的hello方法遇到404错误.每当我点击"评价艺术家"按钮时,它都会给我错误,但home.html,hello.html和artist.html的模板都是正确的.我不知道我的代码的哪一部分是错的.有帮助吗?

@app.route("/",methods=['GET','POST'])
def login():
    if request.method=="GET":
        return render_template("home.html")
    if request.method=="POST":
        if (request.form["button"]=="login"):
            return render_template("hello.html",name=request.form["name"])

@app.route("/hello",methods=['GET','POST'])
def hello():
    if request.method=="GET":
        if(request.form["button"]=="rate artists"):
            return render_template("artist.html")
Run Code Online (Sandbox Code Playgroud)

python flask http-status-code-404

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

django heroku媒体文件404错误

我最近向Heroku部署了一个Django应用程序并上传了一些媒体文件,一切似乎都运行良好,直到昨天我再次尝试访问该应用程序并发现它发出了404错误.

任何想法为什么会这样?

settings.py:

import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
import dj_database_url
#DATABASES['default'] =  dj_database_url.config()
DATABASES = {'default':  dj_database_url.config(default='postgres://localhost')}

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']

STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = '/media/'
Run Code Online (Sandbox Code Playgroud)

urls.py

urlpatterns = patterns('',
    (r'', include(application.urls)),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    (r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.MEDIA_ROOT}),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.STATIC_ROOT}),

)
Run Code Online (Sandbox Code Playgroud)

django heroku http-status-code-404

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

Symfony2在错误页面上包含表格(404)

我创建了一个自定义错误模板

app/Resources/TwigBundle/views/Exception/error404.html.twig

app/Resources/TwigBundle/views/Exception/exception_full.html.twig

用于开发以将布局更改为我想要的内容.这很好用.但是,只要我使用添加表单(例如我的搜索或联系表单)

{{ include ('MyCoreBundle:Default/forms:myCustomForm.html.twig' ) }}

或直接输入代码,显示a ResourceNotFoundException和a NotFoundHttpException而不是404页面.

有没有办法在错误模板上显示表单?

forms error-handling http-status-code-404 symfony symfony-2.4

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

如何捕获和重定向有效但无效的资源 ID 的 rails 路由?

match '*path' => redirect('/'), via: :all if Rails.env.production? 很好地处理事情,但它不能正确地捕捉这样的情况

/root.com/articles/293 其中 293 是数据库中不存在的文章 ID。

在这种情况下,它仍然重定向到默认的 404 页面,这在 heroku 上是丑陋的“出现问题”页面。

如何利用“有效的 url,但无效的资源 ID” url 来控制其重定向到我想要的位置?

redirect routes ruby-on-rails path http-status-code-404

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

404 auth0 更新用户(PUT)

当尝试使用 auth0 发出 PUT 请求时,我不断遇到 404“用户未找到”错误。

我正在尝试更新用户,并使用他们的文档告诉我使用的确切端点进行此 API 调用。

当从他们的文档中拨打电话时(他们有一个内置测试),我发送的正文一切正常,并且我收到了 200 成功消息。

当我尝试从我的应用程序进行相同的调用时,我不断收到 404 用户未找到错误。

但是,当我使用相同的端点user_id从我的应用程序获取时,一切正常(证明我的 cliendID 配置正确)。

为什么会失败?

var updateAuthUser = function(){
    var request = {
        "user_metadata": {
            "springboardID": 100055
        }
    }

    var update = $http.put('https://app36591925.auth0.com/api/v2/users/auth0%7C5606b3c4b0c70b49698612fc', request);

    update.then(function(response) {
            console.log("update success", response);
        }, function(response) {
            console.log("update failure", response);
        });
    return update;
}
Run Code Online (Sandbox Code Playgroud)

工作 GET 请求:

var getAuthUser = function(){
    $http.get('https://app36591925.auth0.com/api/v2/users/auth0|5606b3c4b0c70b49698612fc')
        .then(function(response){
            console.log("response", response);

            var deferred = $q.defer();
            deferred.resolve(response);
            return deferred.promise;
        });
}
Run Code Online (Sandbox Code Playgroud)

put http-status-code-404 angularjs auth0

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

Express js为目录中的所有静态文件获取404

为了方便我的静态文件,我有多个目录。我的一些静态文件在客户端目录中,一些与仪表板相关的文件在 src 目录中,所以现在我的目录结构如下

/
|
client //static files and other stuff
server //server side express, app, controller, models etc
src //other static files
Run Code Online (Sandbox Code Playgroud)

我有两个角度应用程序,一个在客户端文件夹中,另一个在 src 文件夹中,我的服务器端路由如下 -

app.route('/app/dashboard-v1').get(function(req,res){
        res.sendFile(path.join(__dirname, '../src', 'index.html'));
    });

    // All undefined asset or api routes should return a 404
    app.route('/:url(api|img|src|auth|components|app|bower_components|assets)/*')
        .get(errors[404]);

    // All other routes should redirect to the index.html
    app.route('/*')
        .get(function (req, res) {
            res.sendFile(path.resolve(app.get('appPath') + '/index.html'));
        });
Run Code Online (Sandbox Code Playgroud)

所以我的第一个 angular 应用程序在 app/dashboard-v1 中,所有其他 url 都重定向到 app2

我正确地获取了我的 app2 中的所有文件,但我的第二个应用程序中的所有其他文件都得到了 404。现在如果我注释掉

//  app.route('/:url(api|img|src|auth|components|app|bower_components|assets)/*')
            .get(errors[404]);
Run Code Online (Sandbox Code Playgroud)

我从第一个应用程序的所有文件中的第二个应用程序中获取我的 index.html …

javascript routes http-status-code-404 express angularjs

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

在http.FileServer上记录404

我正在dirPath使用jpeg图像http.FileServer:

http.Handle("/o/", http.StripPrefix(
    path.Join("/o", dirPath), http.FileServer(http.Dir(dirPath))))
Run Code Online (Sandbox Code Playgroud)

我不明白的是如何在对不存在的文件发出请求时进行记录.我可以看到当我使用浏览器发出请求时找不到http.FileServer返回的404页面,但是在服务器控制台上没有找到.

http go http-status-code-404

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

Azure 应用服务为 GET/请求返回 404

我们有一个应用服务,它是 Azure 中的 ASP.NET 应用。我们已经为 / 路由定义了 200 OK 响应。当我们尝试从浏览器或邮递员点击 / 端点时,我们会得到想要的结果。但是在 Azure App Insights 中,我们注意到每 5 分钟 GET / request 失败。

DNS 配置 从提供的图片中,您可以看到默认的 Azure 路由(qualitykitchen.azurewebsites.net)仍然存在,因为我们还没有找到删除它的方法。

来自 Azure 的 404 错误屏幕截图 请务必注意,生成 404 的请求是 (qualitykitchen.azurewebsites.net) 的默认路由,而不是我们通过自定义 DNS 设置的自定义路由 (api-staging.qualitykitchen.co)。

因为我们启用了“始终开启”,我们非常确定这些请求只是 Azure ping 服务以使其保持活动状态。不幸的是,它似乎对呼叫的路线感到困惑。

我们假设请求来自 Azure 是否正确?我们如何引导 Azure 调用我们的自定义路由?

dns azure http-status-code-404

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

如何访问 Google Cloud 上我的 Wordpress 网站的 .htaccess 文件?

我将一个网站从一个网络主机迁移到另一个(即 Google Cloud),但是我在将我的永久链接从普通名称更改为帖子名称时遇到了问题。我想让网站在 url 上显示页面的名称,但我不知道如何在 Google Cloud 上访问我的 .htaccess 文件,看看这是否是导致它的原因。

网站页面上的错误是 404 Not Found。但是,如果永久链接位于普通而不是 %postname% 上,则可以找到这些页面。

我正在处理一个 wordpress 文件。

我试图在 wordpress 仪表板中将永久链接更改为 %postname%,但收到错误消息。我还尝试查看插件是否存在问题,但其永久链接需要处于“普通”设置。

wordpress .htaccess permalinks http-status-code-404 google-cloud-platform

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