开发者

Mod rewriting a link with query to another subdomain

开发者 https://www.devze.com 2023-02-26 18:49 出处:网络
I\'ve got links with a query string that I would like to rewrite to a different subdomain. I\'ve tried the following :

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

精彩评论

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