这是我当前的 nginx 配置
server_name web.com;
server_tokens off;
root /usr/share/nginx/html/web;
index index.php;
if ( $request_uri ~ "/index.(php|html?)" ) {
rewrite ^ /$1 permanent;
}
location / {
try_files $uri $uri/ /index.php?$args =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
我正在尝试做的事情:
web.com?page=somepage&other_arg=arg&..
重写为web.com/somepage/arg/...
.
我的方法不起作用,有时会出现错误:failed (104: Connection reset by peer) while reading response header from upstream
或accept4() failed (24: Too many open files)
- 仅允许通过浏览器 URL 直接访问根文件夹中的 index.php。其他文件和目录无法通过浏览器访问(但可以通过GET、POST等)
我使用了internal
指令,按预期工作,但是我无法为 index.php 设置异常
有人能建议一种最佳方法吗?