Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Need Help With The Header() Function, I am redirecting from my old site
Amezis
post Nov 7 2005, 02:54 PM
Post #1


Privileged Member
*********

Group: Members
Posts: 535
Joined: 14-February 05
From: Oslo, Norway
Member No.: 3,759



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:

CODE
<?php
header("Location: http://www.global-rs.com" . $_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 trap17 (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?
Go to the top of the page
 
+Quote Post
electriic ink
post Nov 7 2005, 04:25 PM
Post #2


Incest is a game the whole family can play.
Group Icon

Group: [MODERATOR]
Posts: 1,234
Joined: 11-February 05
From: Heaven
Member No.: 3,709
myCENT:READY[115.88]



Try this code:

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.....
Go to the top of the page
 
+Quote Post
Amezis
post Nov 7 2005, 06:54 PM
Post #3


Privileged Member
*********

Group: Members
Posts: 535
Joined: 14-February 05
From: Oslo, Norway
Member No.: 3,759



Thanks, but there were some errors with your code.
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! biggrin.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Getting List Of Directories And Files Using Php(6)
  2. How To Use A Link To Call Function In Php?(8)
  3. Include File.php?id=something(13)
  4. Php Header Problem(11)
  5. Explode Function Help(1)
  6. Header Redirect Errors(5)
  7. Beginner's Php Tutorial Online At My Site(12)
  8. How Good Is This Data Cleaning Function?(2)
  9. The Extract() Function(6)
  10. Cms Opensource(1)
  11. Error With Joomla Template(1)
  12. Use Bb Code On Your Site!(7)
  13. [php] Header Function(2)
  14. [php](simple) Using Functions To Combine Values In A Form(2)
  15. Php Problems(3)
  1. New Arisen Site Problem(2)
  2. Mail() Clone(5)
  3. The Best Zip Function(1)
  4. Php Explode Function Help(4)
  5. Displaying Your Phone Number On A Wap Site(3)
  6. How To Check If Fsockopen Function Is Enabled?(2)
  7. Connecting Php Site To Database(6)
  8. Html Site With Login(2)
  9. Arrays Outside A Function(3)
  10. Xbox Gamertag Profile On Site(2)
  11. Endif function?(6)
  12. PHP Function To Add Previous and Next Page Feature(5)
  13. Search Engine/ Function(0)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 05:22 PM