开发者

Mod rewriting a link with query to another subdomain

I've got links with a query string that I would like to rewrite to a different subdomain. I've tried the following :

RewriteRule ^/forum/viewtopic.php(.*)$ http://sub2.domain.com/viewtopic.php$1 [R=301,L,QSA]

as well as :

RewriteCond %{QUERY_STRING}

RewriteRule ^forum/viewtopic.php(.*) http://sub2.domain.com/forum/viewtopic.php?%1

As you can imagine, it d开发者_开发知识库idn't fly. Most of the examples I've seen involved specifying the actual query string, however, my links have several variables passed and not always in the same order. Is it possible to rewrite a URL based on viewtopic.php?(anything onward)

Original Links :

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

New Links :

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


As simple as :

RewriteRule ^forum/viewtopic.php$ http://sub2.domain.com/forum/viewtopic.php [R=301, L]

No need for any [QSA] since you don't modify the Query string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜