Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx重写规则,多页_Nginx_Rewrite - Fatal编程技术网

Nginx重写规则,多页

Nginx重写规则,多页,nginx,rewrite,Nginx,Rewrite,您好,我在编写nginx重写规则时遇到一些问题 以下是我到目前为止的情况: location / { rewrite ^/handel/(.*)/(.*)/(.*)/(.*)$ /test.php?cat=$1&underCat=$2&underUndercat=$3&name=$4 last; if (!-e $request_filename){ rewrite ^(.*)$ $1.php last; }

您好,我在编写nginx重写规则时遇到一些问题

以下是我到目前为止的情况:

location / {
    rewrite ^/handel/(.*)/(.*)/(.*)/(.*)$ /test.php?cat=$1&underCat=$2&underUndercat=$3&name=$4 last;

    if (!-e $request_filename){
            rewrite ^(.*)$ $1.php last;
        }
    try_files $uri $uri/ /index.php?$query_string = 404;
}
我想做的是:

/handel/(.*)/(.*)/(.*)/(.*)$ -> /page1.php?cat=$1&underCat=$2&underUnderCat=$3&name=$4
/handel/(.*)/(.*)/(.*)$ -> /page2.php?cat=$1&underCat=$2&underUnderCat=$3
/handel/(.*)/(.*)$ -> /page3.php?cat=$1&underCat=$2
/handel/(.*)$ -> /page4.php?cat=$1
/handel/ -> /page5.php

请注意不同的页面。

您具体遇到了哪些问题?我无法让它正常工作。要在这方面获得最佳帮助,您需要提供更多细节。为什么不起作用?你是否遇到了某种错误,预期的行为不是你预期的吗?如果是这样,你会得到什么样的行为?你期望得到什么样的行为?“我不能让它工作”是不够具体。我想我指定了它相当清楚的OP。我想重写左边的网址到右边的<代码>/handel/(.*)/(.*)/(.*)/(.*)$->/page1.php?cat=$1&underCat=$2&underCat=$3&name=$4/handel/(.*)/(.*)/(.*)$>/page2.php?cat=$1&underCat=$2&underUnderCat=$3/handel/(.*)/(.*)$>/page3.php?cat=$1&underCat=$2/handel/$2/page4.php?cat/->/page4.php只匹配您的请求。您可以为每个目录深度尝试5个regex位置,并在每个目录中使用不同的try_files指令来捕获。