nginx伺服器怎樣去掉url中的index.php?
阿新 • • 發佈:2021-01-28
技術標籤:php
將location程式碼塊巢狀在server程式碼塊中,如下所示:
server { listen 80; server_name yourdomain.com; root /home/yourdomain/www/; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } access_log logs/yourdomain.log combined; }
完成後,重啟nginx伺服器.