gpt4 book ai didi

nginx 别名+位置指令

转载 作者:行者123 更新时间:2023-12-03 04:21:41 31 4
gpt4 key购买 nike

server {
listen 80;
server_name pwta;
root html;

location /test/{
alias html/test/;
autoindex on;
}
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/test/ 被替换,例如location/testpath/ 它不起作用(未指定输入文件)。我假设根据别名指令的解释,“位置”部分被删除,因此 /testpath/info.php 将导致 html/test/info.php

感谢您的任何建议。

最佳答案

nginx alias

    server {
listen 80;
server_name pwta;
index index.html index.php;
root html;

location /testpath/ {
alias html/test/;
}
location ~ ^/testpath/(.+\.php)$ { ### This location block was the solution
alias html/test/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$1;
include fastcgi_params;
}
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;
}

关于nginx 别名+位置指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10084137/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com