Redirect problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Will

    Redirect problem

    I downloaded a PHP webcounting script from the web. I got it working on
    my home test server but the same thing does not work when I put on my
    hosting server.

    the string that calls the script is:
    <a href="webcounte r.php?src=http://www.cnn.com"> CNN </a>


    The code that handles it is:

    $extra_ext = "redirect:" ;

    if (basename($PHP_ SELF)=="webcoun ter.php") {
    // we are indexing a different file
    $source = $_GET['src'];

    $tmp = substr($source, 0, 6);

    if ($tmp=='http:/' || $tmp=='https:' || $tmp=='ftp://') {
    $location=$sour ce;
    $rpage = $extra_ext.$sou rce;

    }
    else {
    $location=$root page.$source;
    $rpage = $extra_int.$sou rce;
    }
    webcounter ($ctype,$rpage) ;
    header ("Location: $location");
    exit;
    }

    I can post some more of the code if anyone needs it. On the host server
    the string is being formed right but the redirect is not working.

  • Pedro Graca

    #2
    Re: Redirect problem

    Will wrote:[color=blue]
    > I downloaded a PHP webcounting script from the web. I got it working on
    > my home test server but the same thing does not work when I put on my
    > hosting server.[/color]

    What are the differences between the two servers?
    Linux/Windows?
    IIS/Apache?
    PHP 4.1.0/PHP 5.0.0?

    and most importantly
    home php.ini / host php.ini ?


    Try inserting at the top of your scripts the two lines that follow so
    that PHP will report the use of uninitialized variables:

    error_reporting (E_ALL);
    ini_set('displa y_errors', '1');


    Happy Bug Hunting :)
    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    • Will

      #3
      Re: Redirect problem

      Test server: Remote server:
      Windows XP pro. Linux
      Apache 1.3.27 Apache 1.3.27
      PHP 4.3.4 PHP 4.3.2

      I did a phpinfo() on the two servers and I did n't see any differences
      that I thought would cause this but then what do I know.

      Pedro Graca wrote:[color=blue]
      > Will wrote:
      >[color=green]
      >>I downloaded a PHP webcounting script from the web. I got it working on
      >>my home test server but the same thing does not work when I put on my
      >>hosting server.[/color]
      >
      >
      > What are the differences between the two servers?
      > Linux/Windows?
      > IIS/Apache?
      > PHP 4.1.0/PHP 5.0.0?
      >
      > and most importantly
      > home php.ini / host php.ini ?
      >
      >
      > Try inserting at the top of your scripts the two lines that follow so
      > that PHP will report the use of uninitialized variables:
      >
      > error_reporting (E_ALL);
      > ini_set('displa y_errors', '1');
      >
      >
      > Happy Bug Hunting :)[/color]

      Comment

      • Pedro Graca

        #4
        Re: Redirect problem

        Will wrote:[color=blue]
        > I downloaded a PHP webcounting script from the web. I got it working on
        > my home test server but the same thing does not work when I put on my
        > hosting server.
        >
        > the string that calls the script is:
        ><a href="webcounte r.php?src=http://www.cnn.com"> CNN </a>
        >
        >
        > The code that handles it is:
        >
        > $extra_ext = "redirect:" ;
        >
        > if (basename($PHP_ SELF)=="webcoun ter.php") {
        > // we are indexing a different file
        > $source = $_GET['src'];
        >
        > $tmp = substr($source, 0, 6);
        >
        > if ($tmp=='http:/' || $tmp=='https:' || $tmp=='ftp://') {
        > $location=$sour ce;
        > $rpage = $extra_ext.$sou rce;
        >
        > }
        > else {
        > $location=$root page.$source;
        > $rpage = $extra_int.$sou rce;
        > }
        > webcounter ($ctype,$rpage) ;
        > header ("Location: $location");[/color]

        Maybe your problem is not the header call, but something on the
        webcounter function ...

        Try a echo() before and after the call to webcounter()

        // since you're debugging this turn on error reporting too
        error_reporting (E_ALL);
        ini_set('displa y_errors', '1');

        echo 'before webcounter()';
        webcounter($cty pe, $rpage);
        echo 'after webcounter()';
        header('Locatio n: ' . $location);
        [color=blue]
        > exit;
        > }[/color]


        --
        USENET would be a better place if everybody read: : mail address :
        http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
        http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
        http://www.expita.com/nomime.html : to 10K bytes :

        Comment

        Working...