laravel訪問路由在nginx服務器上沒法處理

用過laravel的童鞋們都知道,訪問路徑通常都是/admin/index這樣的形式,但是在nginx服務器上運行代碼時卻會出現沒法找到頁面的狀況,這是由於nginx沒有配置好。php

在nginx的配置文件中找到如下代碼:nginx

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

而後修改爲:laravel

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?$query_string;
        }

而後重啓服務器運行便可。服務器

相關文章
相關標籤/搜索