.htaccess - 从特定 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 文件与 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]
推荐阅读
- linux - 使用 grep 的两个文件之间的相似性,为什么会这样: grep -i "-ffile1" file2
- python - Python:尝试遍历列表并仅打印正值时出错
- java - 如何防止视图重叠?
- database-design - 为星型模式中的分辨率设置时间维度
- encryption - FFmpeg concat demuxer 和处理加密块
- database - Mongodb 有条件地聚合返回数据
- jenkins - Jenkins:java.lang.NoSuchMethodError:在步骤中找不到这样的 DSL 方法“$”
- r - 在 Quanteda 中构建语料库,同时跟踪 ID
- dns - 带有绑定和从属的 Certbot rfc2136 挑战
- django - Django、mozilla-django-oidc 和管理员