Jump to content
xisto Community
Sign in to follow this  
Amezis

Need Help With The Header() Function I am redirecting from my old site

Recommended Posts

Over a month ago, I bought a domain name for my site, but my site is still not indexed. I did everything needed to get indexed, but I forgot one thing: The old site had exactly the same content as the new one. So I had duplicate content. Therefore, I want my old site to redirect the user to the new site with this script:


<?phpheader("Location: URL . $_SERVER['REQUEST_URI']); exit;?>

global-rs.com is my new URL. However, on my old site, which I will be placing this code on, there is a problem: It was a free host, not Xisto (I already had another site hosted here when creating the other site). They didn't offer subdomain, it was just a directory: thehost.com/globalrs. The code shown above will redirect me to global-rs.com/globalrs/someurl But is there a way to remove globalrs/ from the redirection, so it will only redirect the user to global-rs.com/someurl?


Share this post


Link to post
Share on other sites

Try this code:

 

<?$thisuri = $_SERVER["REQUEST_URI"];$noSubDir = str_replace("/global_rs", "/", $thisuri);header("location: http://globalrs.com" . $noSubDir);?>

$noSubDir uses php's str_replace function to replace all instances of /global_rs with /.

 

Should work properly.....

Share this post


Link to post
Share on other sites

Thanks, but there were some errors with your code.

<?$thisuri = $_SERVER["REQUEST_URI"];$noSubDir = str_replace("/globalrs/", "/", $thisuri);header("location: http://global-rs.com" . $noSubDir);?>
This is how it should be. But anyway, thanks alot for the help! :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.