Apache 重定向url已在htaccess中重写

Apache 重定向url已在htaccess中重写,apache,.htaccess,redirect,Apache,.htaccess,Redirect,我有书面访问权限 我的实际网址是 https://www.example.com/index.php?route=information/partnership_form 改写为 https://www.example.com/for-brands/partner-with-us 按照我写的规则,这很好 `RewriteRule ^for-brands/partner-with-us$ https://www.example.com/index.php?route=information/p

我有书面访问权限 我的实际网址是

https://www.example.com/index.php?route=information/partnership_form
改写为

https://www.example.com/for-brands/partner-with-us
按照我写的规则,这很好

`RewriteRule ^for-brands/partner-with-us$ https://www.example.com/index.php?route=information/partnership_form [NC,L]`
但如果有用户直接访问,我需要重定向

下面是我的代码重定向,但我已经尝试了许多方法,从stackoverflow的其他链接仍然我找不到任何解决方案

rewriterule ^index\.php?route=information\/partnership_form(.*)$ /for-sports-brands/partner-with-us$1 [r=301,nc]

你不能那样操纵查询字符串。您需要使用重写条件

RewriteEngine on

RewriteCond %{QUERY_STRING} ^route=information/partnership_form [NC]
RewriteRule ^index\.php$ /for-brands/partner-with-us? [NC,L,R]

重写目标末尾的很重要,因为它丢弃了旧的查询字符串。

我尝试了你的代码,但它的重新调整错误页面没有正确重定向,如果我用重写规则(如
rewriterule^index\.php$/为体育品牌/与我们合作伙伴)编写体育运动,会有什么不同吗?[NC,L,R]