.htaccess - Changing query string key name with htaccess rewrite rule
问题描述
We are changing affiliate software and I can't figure out how to rewrite the name of the query string key to achieve the following:
https://www.example.com/path/to/productx?old_key_name=numeric_value
Redirect to:
https://www.example.com/path/to/productx?new_key_name=numeric_value
So far I have:
RewriteCond %{QUERY_STRING} ^old_key_name=([0-9]+)
RewriteRule ^ %{REQUEST_URI}?new_key_name=%1 [L,R=301]
Which doesn't retain the full path to the product, but results in:
https://www.example.com/index.php?new_key_name=numeric_value
/path/to/productx/
is missing.
I'm placing the rule at the bottom of a Joomla htaccess file on an Apache server. Can the full path to the product be added to the redirect rule?
解决方案
我刚刚将规则移到 htaccess 文件的顶部,它按预期工作。我猜默认的 Joomla SEF 重写规则是问题所在。
推荐阅读
- javascript - 如何通过 localStorage.getItem() 恢复值
- node.js - 使用 SQL Server 和 Hapi.Dev 登录的 Auth.js 文件出现问题
- python - 带有重复项的子集,仅返回空列表的问题
- selenium - 动态 WebElement 使 ElementNotInteractable 异常
- javascript - 想要反转 JavaScript “回到顶部”按钮以制作匹配的“跳到底部”按钮
- python - Rust vs python 程序性能结果问题
- html - JQuery 使用以字符串开头的类隐藏元素
- pycharm - Pycharm 停止在 mobaxterm 和 wsl2 上工作
- python - Python:使用 % 符号返回精度
- java - Servlet 构建失败:模块尚未部署