Nginx删除网址的最后一部分

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

现在我在自定义网站上拥有网址,例如

http_//domain.com/there-is-the-key?download=123456

并且我正在尝试将“?”之后的最后一部分硬重写,只希望关键字在URL中。这是我简单的nginx配置:

 # 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;   

但没有-网址相同。

hyjdbsc 回答:Nginx删除网址的最后一部分

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3121325.html

大家都在问