gpt4 book ai didi

nginx - 为什么 Laravel 在所有路由都有效时仍然记录 NotFoundHttpException?

转载 作者:行者123 更新时间:2023-12-04 17:22:40 25 4
gpt4 key购买 nike

我所有注册的路线都在工作。它们显示 View ,但在每次请求时,我的日志文件中都会显示 NotFoundHttpException。

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

记录在每个请求上的错误(即使 View 显示):

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 配置无关。

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

正如 Rubens Mariuzzo 所提到的,access.log 显示图标的状态为 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);
});

关于nginx - 为什么 Laravel 在所有路由都有效时仍然记录 NotFoundHttpException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18245812/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com