Htaccess - 在重定向中使用查询字符串作为文件夹名称

Htaccess - Use query string as folder name in redirect

提问人:Paulo 提问时间:9/14/2023 更新时间:9/14/2023 访问量:8

问:

我正在尝试重定向自

https://example.com/?s=QUERY

https://example.com/search/keyword/QUERY/search-in/product/cat-in/all/search-other/product

我尝试了以下代码

RewriteCond %{QUERY_STRING}  ^s=(\w+)$
RewriteRule (.*)  https://example.com/%1  [R=302,L]

这给了我这个结果

https://example.com/search/keyword/QUERY?s=QUERY/search-in/product/cat-in/all/search-other/product

出于某种原因,我得到的查询字符串重复,并且参数名称介于两者之间。 我应该在此代码中修复什么以仅获取查询字符串而不获取其余部分?

Apache .htaccess 重定向

评论

1赞 CBroe 9/14/2023
用问号结束替换 URL,或使用 QSD 标志

答: 暂无答案