Mod将带有查询的链接重写到另一个子域

| 我有一个带有查询字符串的链接,我想将其重写为另一个子域。我尝试了以下方法:
RewriteRule ^/forum/viewtopic.php(.*)$ http://sub2.domain.com/viewtopic.php$1 [R=301,L,QSA]
以及 :
RewriteCond %{QUERY_STRING}

RewriteRule ^forum/viewtopic.php(.*) http://sub2.domain.com/forum/viewtopic.php?%1
可以想象,它没有飞。我见过的大多数示例都涉及指定实际的查询字符串,但是,我的链接传递了多个变量,但并不总是以相同的顺序进行。是否可以基于viewtopic.php重写URL? 原始链接:
sub1.domain.com/forum/viewtopic.php?p=123&sid=c75edda9

sub1.domain.com/forum/viewtopic.phpt=321&start=0&postdays=0&sid=6e97b05

sub1.domain.com/forum/viewtopic.php?t=45&view=next&sid=f799
新链接:
sub2.domain.com/forum/viewtopic.php?p=123&sid=c75edda9

sub2.domain.com/forum/viewtopic.php?t=321&start=0&postdays=0&sid=6e97b05

sub2.domain.com/forum/viewtopic.php?t=45&view=next&sid=f799
    
已邀请:
就像:
RewriteRule ^forum/viewtopic.php$ http://sub2.domain.com/forum/viewtopic.php [R=301, L]
不需要任何[QSA],因为您无需修改​​查询字符串。     

要回复问题请先登录注册