RE: [PHP] Redirect code problem
| From: | Ozemail ) | Date: | Wed, 25 Oct 2000 22:59:09 +0000 |
| Subject: | RE: [PHP] Redirect code problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21961@lists.php.net to get a copy of this message | ||
Try this function basename();
$path = $GLOBALS["HTTP_REFERER"];
$file = basename($path);
http://www.php.net/manual/function.basename.php
> -----Original Message-----
> From: Richard McLean [mailto:designeffect@one.net.au]
> Sent: Thursday, October 26, 2000 4:09 AM
> To: php-general@lists.php.net
> Subject: [PHP] Redirect code problem
>
>
> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>