gpt4 book ai didi

apache - Mod_重写: Include query string when redirecting

转载 作者:行者123 更新时间:2023-12-03 03:59:25 24 4
gpt4 key购买 nike

我在 mod_rewrite 方面遇到了一个小问题。这是我的代码:

RewriteEngine on 
RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L]

这几乎有效,如果我访问 oldsite.com/apage.php,我会被重定向到 newsite.com/moved.php?q=apage.php。
但是,如果我转到 oldsite.com/apage.php?var=15,我会再次重定向到 newsite.com/moved.php?q=apage.php。
我怎样才能使oldsite.com/apage.php?var=15重定向到newsite.com/moved.php?q=apage.php?var=15非常感谢!

最佳答案

使用QSA flag将原始请求的查询自动附加到新查询中:

RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L,QSA]

关于apache - Mod_重写: Include query string when redirecting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4836355/

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