将此url重定向到另一个网站


redirect to another website this url

我有这两个链接作为示例:

http://thisismysite.com/news/news.aspx?id=2221
http://thisismysite.com/news/news.aspx?id=4321
etc etc 

如果你打开这个链接,它应该会将你重定向到另一个具有相同参数的网站:

http://otherwebsite.com/news/news.aspx?id=2221
http://otherwebsite.com/news/news.aspx?id=4321

这可能吗?

感谢

如果get param id带有数值,则可以为整个域设置301重定向。

.htaccess文件:

RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)id=[0-9](&|$) [NC]
RewriteRule ^(.*)$ http://otherwebsite.com/$1 [L,R=301,NC]

如果你使用PHP,你可以使用这个:

header('Location:http://newdomain.com'. $_SERVER["REQUEST_URI"]);

使用htaccess:

RewriteRule ^(.*) http://newdomain.com%{REQUEST_URI} [R=301,L]