• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

[PHP] Redirect forumpages to new domain

Peo

Administrator
Staff member
Admin
At another site I run I have recently moved a forum from one domain to a new domain. I now need a redirect from the old location of the threads to the new location.

For instance:
the old
bio.nu/forum/index.php?showtopic=581
should redirect to the new location
filmsnack.se/index.php?showtopic=581

All forumpages are located at index.php so all the php file has to do is replace bio.nu/forum with filmsnack.se and redirect to that new location

Anyone?
 
not sure if i understood it correctly. will the old forum still be up and you just want to redirect them to the new domain? if so, you can put this in the header file (or any file which is included in all forum pages)
PHP:
$old_url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$new_url = str_replace('bio.nu/forum', 'filmsnack.se', $old_url);
header('location: '.$new_url);
 
Last edited:
Try something like
PHP:
header( 'location: www.fimsnack.se' . $_SERVER['REQUEST_URI']);

i think it should work that way
 
yeah I think Hugoleite's is simplier, just add http://
PHP:
header( 'location: http://www.fimsnack.se' . $_SERVER['REQUEST_URI']);
 
Hmmm thats odd... could you please post the error you are getting ?

[ --- Edit --- ]
Or try something like this
PHP:
$goThere = "http://www.filmsnack.se{$_SERVER['REQUEST_URI']}";
header( "location: {$goThere}" );
 
Last edited:
PHP:
header( "http://www.filmsnack.se/index.php?{$_SERVER['QUERY_STRING']}" );

I got it, in www.filmsnack.se you don't have the '/forum/' thats the reason for the 404, so this one should work since it only adds the URL parameters that come after the '?' mark.
 
Back
Top