vForums Support Banner



 

Welcome Guest! Please Login or Register
vForums Support :: Programming & Coding :: Programming Discussion :: Domain Change Redirection - View Topic
Topic Rating: *****
Printable View
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
Domain Change Redirection (15th Jan 10 at 10:51am UTC)
Lets say I change my domain to newsite.com from dancingwithross.com. So how can I get dancingwithross.com/index.php/pagetitle=nightclub to redirect to newsite.com/index.php/pagetitle=nightclub ? This I want to do because a login has to be done separately on both, and needing to change thousands of links to the new domain, so redirection would be easier.
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: Domain Change Redirection (15th Jan 10 at 11:29pm UTC)
<?php

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

?>

{Smile}

rroll.to— Shorten a link, rickroll your friends.
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
Re: Domain Change Redirection (16th Jan 10 at 1:14am UTC)
Would this work, for say a PHPBB forum? Where both domains are tied to the same exact host?
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: Domain Change Redirection (16th Jan 10 at 2:03am UTC)
 
Would this work, for say a PHPBB forum? Where both domains are tied to the same exact host?


The REQUEST_URI statement returns everything after (and including) the "/", so it will work for any page, provided that code snippet is on it. I know there's also a way to do it with .htaccess, but I'm not very good with that, so Ross will probably have to help you out with that. {Wink}

rroll.to— Shorten a link, rickroll your friends.
Michael
Moderator
*****

[Avatar]
Recoding the future

Posts: 4,043
Status: Offline
Gender: Male
Location: UK
Joined:  

Additional Groups:
Coding Team
***


Reputation: 58%  


pmtwittervForum
Re: Domain Change Redirection (16th Jan 10 at 3:49am UTC)
 
<?php

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

?>

{Smile}


Surely that'd constantly loop, an IF statement is required! {Wink}
Marc
vChat Developer
*****
I <3 Rossy

Posts: 3,388
Status: Offline
Gender: Male
Location: Ontario, Canada
Age: 32
Joined:  

Additional Groups:
Coding Team
***


Reputation: 40%  


pmwww
Re: Domain Change Redirection (16th Jan 10 at 7:56pm UTC)
 
 
<?php

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

?>

{Smile}


Surely that'd constantly loop, an IF statement is required! {Wink}


From what I understand, he will have two copies of the site. If he is running both sites off the exact same files, then yes, he will need an if statement. {Wink}

If I misunderstood, though, you would need this code:

<?php


if($_SERVER['SERVER_NAME'] == "www.oldsite.com")
{

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

}
?>

rroll.to— Shorten a link, rickroll your friends.
ashkir
Full Member
***

[Avatar]

Posts: 1,159
Status: Offline
Gender: Male
Location: Cali!
Age: 36
Joined:  
Reputation: 42%  


pmtwitterskypemsnyahoo
Re: Domain Change Redirection (19th Jan 10 at 1:54pm UTC)
 
 
 
<?php

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

?>

{Smile}


Surely that'd constantly loop, an IF statement is required! {Wink}


From what I understand, he will have two copies of the site. If he is running both sites off the exact same files, then yes, he will need an if statement. {Wink}

If I misunderstood, though, you would need this code:

<?php


if($_SERVER['SERVER_NAME'] == "www.oldsite.com")
{

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

}
?>


That works! Thank's marc!
 Printable View

All times are GMT+0 :: The current time is 12:57pm
Page generated in 0.6407 seconds
This Forum is Powered By vForums (v2.4)
Create a Forum for Free | Find Forums