加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx – 为什么Laravel在所有路由工作时仍然记录NotFoundHttpE

发布时间:2020-12-13 21:34:33 所属栏目:Nginx 来源:网络整理
导读:我所有注册的路线都在工作.它们显示视图,但在每个请求中都会在我的日志文件中显示NotFoundHttpException. 我正在使用NGINX.可能是我的NGINX配置吗? 每个请求记录的错误(即使视图显示): log.ERROR: exception 'SymfonyComponentHttpKernelExceptionNotF

我所有注册的路线都在工作.它们显示视图,但在每个请求中都会在我的日志文件中显示NotFoundHttpException.

我正在使用NGINX.可能是我的NGINX配置吗?

每个请求记录的错误(即使视图显示):

log.ERROR: exception 'SymfonyComponentHttpKernelExceptionNotFoundHttpException' in /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1429
Stack trace:
#0 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1050): IlluminateRoutingRouter->handleRoutingException(Object(SymfonyComponentRoutingExceptionResourceNotFoundException))
#1 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1014): IlluminateRoutingRouter->findRoute(Object(IlluminateHttpRequest))
#2 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(530): IlluminateRoutingRouter->dispatch(Object(IlluminateHttpRequest))
#3 /usr/share/nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(506): IlluminateFoundationApplication->dispatch(Object(IlluminateHttpRequest))
#4 /usr/share/nginx/www/example-staging/releases/20130815024541/content/index.php(49): IlluminateFoundationApplication->run()
#5 {main}

NGINX配置:

# Redirect www.
server {
    listen 80;
    server_name www.example.com;
    rewrite ^(.*) http://example.com$1 permanent;
}

server {
    listen 80;
    server_name example.com;

    access_log /var/log/nginx/example.com/access.log;
    error_log /var/log/nginx/example.com/error.log;
    rewrite_log on;

    root /usr/share/nginx/www/example/current/content;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~* .php${
        # Server PHP config.
        fastcgi_pass                    unix:/var/run/php5-fpm.sock;
        fastcgi_index                   index.php;
        fastcgi_split_path_info         ^(.+.php)(.*)$;

        # Typical vars in here,nothing interesting.
        include                         /etc/nginx/fastcgi_params;
        fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    if (!-d $request_filename) {
        rewrite ^/(.+)/$/$1 permanent;
    }

    location ~ /.ht {
        # (deny .htaccess)
        deny all;
    }
}
最佳答案
这与NGINX配置无关.

favicon的路径不正确.我假设找到了所有资源,因为在Web检查器中,所有状态都是OK或304.我猜检查员没有在网络选项卡中显示favicon.

正如Rubens Mariuzzo所说,access.log显示favicon是状态500.

作为旁注,如果您希望Laravel停止将404s / Resource Not Found记录为日志文件中的错误,您可以编辑您的global.php文件,如下所示.

App::error(function(Exception $exception,$code)
{
    // Don't log 404s
    if ($exception instanceof SymfonyComponentHttpKernelExceptionNotFoundHttpException) {
        return;
    }

    Log::error($exception);
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读