我正在构建一个NGINX虚拟主机:
我的问题是这实际上会创建一个无限重定向循环。我在这里缺少什么?
server {
server_name ~^my\.domain\.com$;
listen 80;
root /path/to/root;
error_page 404 /404.php;
location ~ \.php$ {
rewrite ^(.*)\.php$ $1 permanent;
break;
}
location / {
index index.php;
try_files $uri $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# rest of fastcgi configuration...
}
}
答案 0 :(得分:0)
首先,您不能拥有两个lapply(resultNorm, #loop over the list elements instead of over an index
function(mat) {
rownames(mat) <- c("a1", "a2", "a3", "a4") #assign rownames
mat})
块。解决方案是在命名位置内处理location ~ \.php$
并避免内部重写为fastcgi_pass
。像这样:
.php
请注意,不再需要location / {
try_files $uri @php;
}
location @php {
try_files $uri.php $uri/index.php =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass ...;
}
location ~* ^(.*)\.php$ {
return 301 $1;
}
指令和index
元素。