Redirect code problem
| From: | Richard McLean | Date: | Wed, 25 Oct 2000 18:08:42 +0000 |
| Subject: | Redirect code problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21881@lists.php.net to get a copy of this message | ||
Hi All,
I'm having a small problem with a piece of code that I'm using to
redirect a page through a script, but only if it isn't already. The
script itself strips the path and query info from the request
before passing it to PHP, so I'm stuck using HTTP_REFERER to
trigger it.
<?php
$ref = explode("/", $GLOBALS["HTTP_REFERER"]);
if (!$ref[4] == "script.exe") {
header ("Location: http://www.myserver.com/cgi-bin/script.exe$PHP_SELF?arg1+arg2");
exit;
}
?>
This works great with files in a second level directory, such as:
http://www.myserver.com/folder/page.html
but it gets stuck in a loop with root level files, such as:
http://www.myserver.com/page.html
presumably because $ref[4] doesn't exist.
Can anyone think of a way to improve this so that it can
work with multi-level files? I've tried a few things out without
success, so I'm stuck here head scratching.
cheers,
Richard