使用http授权将htaccess重写为nginx

时间:2017-09-21 13:46:24

标签: apache .htaccess mod-rewrite nginx

我在.htaccess中有一个apache2重写规则:

RewriteRule ^down.pl down.pl [E=HTTP_AUTHORIZATION:%{HTTP:AUTHORIZATION},L,QSA]

请问,如何为nginx重写它?

我的nginx代码如下:

setenv HTTP_AUTHORIZATION:$http_authorization;
rewrite ^/down.pl /down.pl last;

但它不起作用,我根本无法启动nginx服务器。

配置:

server {
    listen   80;
    server_name www.example.tld example.tld;
    root /srv/!example.tld/!www;

    index  desktop.pl index.html index.htm core.tom core.pl;

    location / {     
        setenv HTTP_AUTHORIZATION:$http_authorization;
        rewrite ^/down.pl /down.pl last;
    }

    location ~ \.pl|cgi|tom$ {
        gzip off;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
        fastcgi_index index.pl;
        fastcgi_param SCRIPT_FILENAME /srv/!example.tld/!www$fastcgi_script_name;
    }
}

0 个答案:

没有答案