0

我有一个关于 nginx 重定向/try_files 的问题:
我在 www.XXXYYY.com 有一个网站(由 ISPConfig3 管理的虚拟主机)在
根目录中有文件夹、index.php 等。
我希望某些文件www.XXXYYY.com/folder21/public/309273.php可以访问www.XXXYYY.com/309273(具有更漂亮的链接)。

但是,我尝试过的所有东西要么根本不起作用,要么下载了 .php 文件而不是由 PHP-FPM 处理......</p>

这是我目前在 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;
}

对此的任何帮助表示赞赏!

4

1 回答 1

0

这就是我最终得到的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 结尾。
eg 格式的文件/data/share/XYZ123-en被重写为/data/share/XYZ-123.php?lang=en.

于 2014-04-23T14:59:56.707 回答