【问题标题】:Nginx server laravel route directory 404 errorNginx服务器laravel路由目录404错误
【发布时间】:2016-06-23 16:37:03
【问题描述】:

最近我在 Nginx 中安装了 Laravel。 Laravel 应用程序主页工作正常,但路由页面出现 404 错误。 我的Nginx 配置如下:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/html;
    index index.html index.htm index.php;

    server_name localhost;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
            #try_files $uri $uri/ =404;
            #try_files $uri $uri/ /index.php$is_args$args;
    }
    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /var/www/html;
    }


    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

当我访问像localhost/lar/public 这样的网址时,它工作正常。 声明了路由,但是当我访问像 localhost/lar/public/test 这样的 URL 时,它会出现 404 错误。

【问题讨论】:

  • 您是否在.env 文件中正确配置了APP_URL
  • 是的,我已经在 .env 文件中正确配置了 APP_URL。但还是不行
  • 你应该将你的根设置为root /home/user_name/Documents/laravel_project_name/public;

标签: php nginx laravel-5


【解决方案1】:

只需将 root 更改为 /var/www/html/lar/public,然后路由正常工作

【讨论】:

    猜你喜欢
    • 2020-12-29
    • 1970-01-01
    • 2018-01-15
    • 2020-04-15
    • 2017-05-31
    • 2013-12-26
    • 2014-12-21
    • 2017-10-20
    • 2018-06-11
    相关资源
    最近更新 更多