Nginx笔记总结十三:sub_filter内容替换

Nginx变异安装加上参数 --with-http_sub_module

配置文件:

location ~* ^/portalproxy/([0-9]*)/portal(.*)$ {
    #sub_filter '302 Found' 'success';
    #sub_filter_once off;
    set $bodyContent '<html><head><title>success</title></head><body><script>location.href="http://$host/portalproxy/portal?url_timetemp
=$1$2";</script></body></html>';
    #rewrite '^/portalproxy/([0-9]*)/portal$' http://$host/portalproxy/portal?url_timetemp=$1 break;
    add_header Content-Type "text/html";
    return 200 $bodyContent;
        }