nginx rewrite url removing subfolder

2019-09-02 03:23发布

I am struggling a bit with rewriting some urls in nginx

I have a site: foo.com/

foo.com/index.html has a link to foo.com/bar.cgi (maybe with with GET arguements)

my cgi resides in /var/www/site/cgi-bin/ and thus it is accesible via foo.com/cgi-bin/bar.cgi

I was hoping the rewrite would remove the cgi-bin part

    location ~ \.cgi$ {
        root /var/www/localhost;
        #rewrite ^/cgi-bin/(.*)$ $1 permanent;

        fastcgi_param SCRIPT_FILENAME/ /var/www/localhost$fastcgi_script_name;
        include /etc/nginx/fastcgi.conf;
        fastcgi_pass unix:/var/run/fcgi.sock-1;
        }

1条回答
祖国的老花朵
2楼-- · 2019-09-02 03:53

From what you describe you only have to point fastcgi to the right place:

fastcgi_param SCRIPT_FILENAME var/www/site/cgi-bin$fastcgi_script_name;
查看更多
登录 后发表回答