nginx - 在 NGINX 中执行 301 重定向时跳过参数
问题描述
第一次在这里发帖。因此,我使用此代码将特定页面从一个域重定向到另一个域。
if ( $request_filename ~ / ) { rewrite ^ https://example.net permanent; }
是否可以选择跳过该代码中的任何内容,包括“?d =”?我不希望 ?d= 之后的任何页面包含在重定向中。
解决方案
如果重写的 URL 以 , 结尾?
,rewrite
则不会复制任何原始参数。
例如:
rewrite ^ https://example.net/? permanent;
有关详细信息,请参阅此文档。
或者,使用更简单的return
表达式:
return 301 https://example.net/;
推荐阅读
- javascript - Bootbox not 不显示弹出模式
- maven - “mvn test”不会将 src/test/resources 的内容复制到输出目录?
- mapbox-gl-js - 是否可以动态添加到 kepler.gl 中的数据集
- r - 如何在条形图(ggplot)中的条形组之间添加空间
- sql - 将查询运行日期和总数保存在 HANA 数据库中的存储过程 - 每天早上 6:30 运行
- python - 为什么 concurrent.futures.ThreadPoolExecutor().submit 不立即返回?
- webpack - Webpack 开发服务器缓存清除
- javascript - 仅操作二维数组的数值
- java - 在java中向服务器发送消息
- javascript - Newsletter2Go - 用 javascript 填写表单后无法正常工作?