Quantcast
Channel: 小惡魔 – 電腦技術 – 工作筆記 – AppleBOY
Viewing all articles
Browse latest Browse all 325

Nginx 搭配 Laravel PHP Framework 設定

$
0
0
Laravel PHP Framework

筆記在 Nginx 設定 Laravel 專案,現在的 PHP Framework 都將 query string 整個導向首頁 index.php,就拿 CodeIgniter 來說,在 Apache 只要設定

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|images|robots\.txt|$)
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

在 Nginx 內只要透過 try_files 即可

location / {
    try_files $uri $uri/ /index.php
}

正常來說 Laravel 直接用上面的設定即可,但是我發現在 $_GET 這全域變數會拿到空值,解法也很簡單,在 Nginx 將 query string 變數帶到 index.php 後面即可

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

Viewing all articles
Browse latest Browse all 325

Trending Articles


HOY PANGIT, MAGBAYAD KA!


Henry el monstruo feliz para colorear e imprimir


Dama y vagabundo para pintar


Girasoles para colorear


Good Morning Quotes


RE: Mutton Pies (jameskoiman)


Hagibis (1946) by Francisco V. Coching


Ka riam ka beit bad ka por riam


Vimeo Create - Video Maker & Editor 1.6.0 by Vimeo Inc


Vimeo 3.42.1 by Vimeo Inc