Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.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删除url中的最后一部分_Nginx_Url Rewriting_Digits - Fatal编程技术网

Nginx删除url中的最后一部分

Nginx删除url中的最后一部分,nginx,url-rewriting,digits,Nginx,Url Rewriting,Digits,对不起,我是nginx配置的新手,但是使用regexp我就可以了 现在我在我的自定义网站上有URL,比如 http//domain.com/有钥匙吗?下载=123456我只想硬重写并删除?下载。。。。从任何URL(不编辑php代码)中,查询字符串不是URI的一部分,因此不能使用rewrite指令进行更改。要去除查询字符串,可以使用set$args”“。要仅删除一个查询参数,请使用regexp。 # if ($request_method !~* ^(GET|HEAD|POST)$ ){retu

对不起,我是nginx配置的新手,但是使用regexp我就可以了

现在我在我的自定义网站上有URL,比如


http//domain.com/有钥匙吗?下载=123456
我只想硬重写并删除?下载。。。。从任何URL(不编辑php代码)中,查询字符串不是URI的一部分,因此不能使用
rewrite
指令进行更改。要去除查询字符串,可以使用
set$args”“。要仅删除一个查询参数,请使用regexp。
 # if ($request_method !~* ^(GET|HEAD|POST)$ ){return 403;}
    location ~ /\. {deny all;}


    location / {
        root       "%hostdir%";
        index      index.php;
    }

          if (!-e $request_filename) {
              rewrite ^(.*)$ /index.php;
            #HERE I'M ADDING NEW RULE#  
              break;
         }

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
rewrite ^(.*)?download.* $1 last;
rewrite ^(.*)?download[^\d]$ $1 last;