【问题标题】:Nginx removing parameters from request in main pageNginx从主页中的请求中删除参数
【发布时间】:2021-06-09 13:39:55
【问题描述】:

美好的一天, 请告诉我如何从站点的主页中删除 GET 请求的参数,以便处理其余参数。也就是说,如果请求时主页上有参数,则重定向到不带参数的站点。

server {
listen 80;
listen [::]:80;

root /var/www/public_html/public;
index index.php index.html index.htm;

server_name mysite.com;

location / {
  try_files $uri $uri/ /index.php?$query_string;
}


 location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
}

}

【问题讨论】:

    标签: nginx redirect webserver


    【解决方案1】:

    未经测试,但下面几行的内容应该可以帮助您

    server {
    listen 80;
    listen [::]:80;
    
    root /var/www/public_html/public;
    index index.php index.html index.htm;
    
    server_name mysite.com;
    
    location / {
      location = / {
           if ($is_args)
               rewrite / permanent;
           try_files $uri $uri/ /index.php?$query_string;
      }
      try_files $uri $uri/ /index.php?$query_string;
    }
    
    
     location ~ \.php$ {
        #include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
    
    }
    

    【讨论】:

      猜你喜欢
      • 2011-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      • 2014-09-06
      • 1970-01-01
      相关资源
      最近更新 更多