nginx:删除fastcgi_script_name的前缀

时间:2017-10-17 15:06:35

标签: php nginx roundcube

我已在虚拟主机中安装了Roundcube:babylon / webmail

location /webmail {
        alias /srv/roundcubemail;
        index index.php index.html;
        # Favicon
        location ~ ^/webmail/favicon.ico$ {
                root /srv/roundcubemail/skins/classic/images;
                log_not_found off;
                access_log off;
                expires max;
        }
        # Robots file
        location ~ ^/webmail/robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        # Deny Protected directories
        location ~ ^/webmail/(config|temp|logs)/ {
                 deny all;
        }
        location ~ ^/webmail/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
                deny all;
        }
        location ~ ^/webmail/(bin|SQL)/ {
                deny all;
        }
        # Hide .md files
        location ~ ^/webmail/(.+\.md)$ {
                deny all;
        }
        # Hide all dot files
        location ~ ^/webmail/\. {
                deny all;
                access_log off;
                log_not_found off;
        }
        #Roundcube fastcgi config
        location ~ /webmail(/.*\.php)$ {
                error_log /var/log/nginx/x.log error;
                access_log /var/log/nginx/scriptsss.log compression;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_split_path_info ^/webmail/(.+\.php)(/.*)$;
                fastcgi_index index.php;
                #fastcgi_param SCRIPT_FILENAME /srv/roundcubemail/$fastcgi_script_name;
                fastcgi_param SCRIPT_FILENAME /srv/roundcubemail/index.php;
                fastcgi_param PATH_INFO $fastcgi_path_info;
        }
}

访问:http://babylon/webmail/时,一切都很好! 但是当访问:http://babylon/webmail/installer/时,我得到的网页没有css也没有javascripts。

例如,我得到:

http://babylon/webmail/installer/skins/larry/images/roundcube_logo.png

但应该是(安装人员):

http://babylon/webmail/skins/larry/images/roundcube_logo.png

问题是:

fastcgi_param SCRIPT_FILENAME /srv/roundcubemail/index.php;

应该是:

fastcgi_param SCRIPT_FILENAME /srv/roundcubemail/$fastcgi_script_name;

在这种情况下,问题是$ fastcgi_script_name获取值:/webmail/index.php或/webmail/installer/index.php。如何从$ fastcgi_script_name中删除“/ webmail /”?

0 个答案:

没有答案