我有一个关于nginx重定向/try_files的问题:
我有一个网站(vhost由ISPConfig3管理),网址是www.XXXYYY.com
在根目录中有文件夹、index.php等等。
我希望www.XXXYYY.com/folder21/public/309273.php
中的某些文件可以在www.XXXYYY.com/309273
上访问(以便有更漂亮的链接)。
然而,我尝试的所有东西要么根本不起作用,要么php文件被下载,而不是由php-FPM处理…
这是我目前正在ISPConfig3:中尝试的nginx vhost指令
这是由ISPConfig3:设置的
location ~ '.php$ {
try_files @php;
}
location @php {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9026;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
这是我在vhost文件底部添加的部分:
location / {
try_files $uri $uri/ /folder21/public/$uri.php /index.php =404;
}
location /folder21/ { internal; }
location /folder21/public/ {
try_files $uri $uri/ $uri.php;
}
感谢在这方面的任何帮助!
这就是我为pydio所做的:
location /conf/ { deny all; }
location /data/ { internal; }
location /data/public/ {
try_files $uri $uri/ $uri.php?$args;
rewrite ^/data/public/([a-z0-9]+)-([a-z]+)$ /data/public/$1.php?lang=$2 last;
}
location ^~ /share/ {
rewrite ^/share/(.*)$ /data/public/$1 last;
}
/data/public
中的PHP文件现在通过/share
提供,而不需要以.PHP结尾。
格式为例如/data/share/XYZ123-en
的文件正在被重写为/data/share/XYZ-123.php?lang=en
。