首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Nginx移除首页请求中的参数

Nginx移除首页请求中的参数
EN

Stack Overflow用户
提问于 2021-03-11 22:33:35
回答 1查看 13关注 0票数 0

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

代码语言:javascript
运行
复制
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;
}

}
EN

回答 1

Stack Overflow用户

发布于 2021-03-11 23:01:21

未经过测试,但下面几行中的一些内容应该会对您有所帮助

代码语言:javascript
运行
复制
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;
}

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66584625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档