http - How to make nginx's rewrite rule (redirect) execute only once?
某草草
某草草 2017-05-16 17:20:30
0
1
597
rewrite ^/(.*).html$ /.html?mode=test redirect;

Now there is a rewrite rule like the above, which can take effect, but it will redirect multiple times. How to modify it so that it only jumps once?

Using break will not work, because break will not modify the browser address bar.

For example:
http://xxx.xx.xx/weather/bug.htmlwill keep jumping and weather/bug.html?mode=test&mode=test&mode= will appear test&mode=test&mode=test&mode=test&mode=test&mode=test&mode……

renew

    location / {
            if($args *~ "mode=formal"){
                rewrite (.*) ? redirect;
                rewrite (.*) ?mode=test redirect;
            }
            else if($args [[不包含mode=test]]){
                rewrite ^/(.*).html$ /.html?mode=test redirect;
            }
            error_page 404 = @nodejs;
    }

I want to configure it in the above way, first judge $args, and then rewrite, I don’t know if it is possible.
And how should I write [[excluding mode=test]]?

某草草
某草草

reply all(1)
小葫芦

Let’s try using last

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template