# Nginx 配置示例代码,用于 ThinkPHP 的伪静态规则
server {
listen 80;
server_name yourdomain.com; # 替换为你的域名
root /path/to/your/project/public; # 替换为你的项目 public 目录路径
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
public
目录路径,这是 ThinkPHP 默认的入口文件所在目录。try_files
指令来处理请求,优先匹配静态文件,如果不存在则交给 index.php
处理。.htaccess
文件,确保安全性。这个配置可以让你的 ThinkPHP 项目在 Nginx 下正常运行,并且支持 URL 重写(伪静态)。
上一篇:php 去除html标签
下一篇:php 获取客户端ip
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站