gpt4 book ai didi

使用 mod_rewrite 重定向查询字符串(反之亦然)

转载 作者:行者123 更新时间:2023-12-04 21:31:26 25 4
gpt4 key购买 nike

假设我有带有查询字符串的 URL,即:/DesignPatterns
使用 mod_rewrite,我如何将它们重定向到:/index.php?book=DesignPatterns
以下正确吗?

 RewriteCond %{QUERY_STRING} (\w+) 
RewriteRule ^index.php?book=%1? [L,R=301]

PS:最初的问题:如何将查询字符串变量与 mod_rewrite 匹配? (2010 年 2 月 12 日,Patrick McElhaney,我征得他的同意)

最佳答案

完整的解决方案是

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?search=$1 [L]

关于使用 mod_rewrite 重定向查询字符串(反之亦然),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49734604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com