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

前端之家收集整理的这篇文章主要介绍了nginx – 为什么Laravel在所有路由工作时仍然记录NotFoundHttpException?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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

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

log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' 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): Illuminate\Routing\Router->handleRoutingException(Object(Symfony\Component\Routing\Exception\ResourceNotFoundException))
#1 /usr/share/Nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Routing/Router.PHP(1014): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /usr/share/Nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Foundation/Application.PHP(530): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#3 /usr/share/Nginx/www/example-staging/releases/20130815024541/vendor/laravel/framework/src/Illuminate/Foundation/Application.PHP(506): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#4 /usr/share/Nginx/www/example-staging/releases/20130815024541/content/index.PHP(49): Illuminate\Foundation\Application->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 Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
        return;
    }

    Log::error($exception);
});
原文链接:https://www.f2er.com/nginx/434344.html

猜你在找的Nginx相关文章