0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[備忘録] nginx + Laravel環境でルート以外404になるエラー解消

Posted at

エラー

nginx + Laravel環境でルートは正しく表示できるものの
それ以外にアクセスしても404になってしまう、、、ルーティングは正しい、、
調べたところ.htaccessの設定が一番に出ていたので見てみたが問題なし、、

解決方法

nginxの設定ファイルを下記に変更して直った。

server {
  listen 80;
    index index.php index.html;
    root /var/www/public;

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

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass php:9000;
    fastcgi_index index.php;
    include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
  }
 }

この一行が
try_files $uri $uri/ /index.php?$query_string;

こっちに入っていたのが原因っぽかった。
location ~ \.php$ {}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?