首页 > 解决方案 > 从特定 URL 中删除所有参数

问题描述

如何获取此原始 URL: https ://www.example.com/search-for-commercial-doors.html?format=json&task=suggestions.suggest&tmpl=component

重写为: https ://www.example.com/search-for-commercial-doors.html

不工作的代码:

RewriteEngine On
RewriteRule ^search-for-commercial-doors\.html$ /search-for-commercial-doors.html? format=json&task=suggestions.suggest&tmpl=component [L]

标签: .htaccess

解决方案


使用您显示的示例,请尝试遵循 htaccess 规则文件。确保您的 htaccess 文件与 search-for-commercial-doors.html 一起存在于同一文件夹中,并在测试 URL 之前清除浏览器缓存。

RewriteEngine ON
RewriteCond ^(search-for-commercial-doors\.html)/?$ $1?format=json&task=suggestions.suggest&tmpl=component [NC,QSA,L]

推荐阅读