Forum Moderators: coopster

Message Too Old, No Replies

Php Redirect Script

         

TomC30

6:09 pm on Jul 23, 2005 (gmt 0)

10+ Year Member



Hi,

Can anyone help me with a php redirect script. I don't know anything about php except how to upload it to my server.

I need a script like "go.php" where I can add the url at the end and have the script redirect it to that url. example: go.php?url=http://www.domain.com

Basically I have some outgoing links that I would like the search engines to think my links are going to pages on my website. Can search engines index php scripts. I don't want the search engines to index the "go.php" because it is just a redirect script. Could I add an id string so search engines would ignore these links? example: go.php?id=12345&url=http://www.domain.com

How can I go about doing this and where can I get a simple script like this?

Any help would be appreciated. Thanks in advance.

encyclo

6:15 pm on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, TomC30. You could try something like this:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location:".$HTTP_GET_VARS['url']."");
exit;
?>

And the HTML link:

<a href="go.php?url=http://www.example.com/">Click here</a>

Then you can exclude go.php in your robots.txt file.

TomC30

5:38 pm on Jul 25, 2005 (gmt 0)

10+ Year Member



Thanks for the help.

What about?

<?php

$url = $_GET['url'];

header("Location: $url");

?>

Does it work better than a 301 move?

vincevincevince

5:42 pm on Jul 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Be careful using that method. If your url contains? or & it won't work properly.

The way around that is to either urlencode() the URL before outputting it into the link, or to parse $_SERVER['REQUEST_URI'] with regex or similar to get the URL as it was typed.