where is // in redirect coming from??

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

    where is // in redirect coming from??

    Hi,

    I'm hoping someone out there has experienced this and can tell me right off
    what is going on. I'm getting a double slash in my URL when I do a redirect
    if my host is a 'web' host, but when my host is localhost (on my development
    machine and not on the web) I get the desired single slash.

    The redirect code is as follows:

    header("Locatio n: http://".$_SERVER['HTTP_HOST'].
    dirname($_SERVE R['PHP_SELF']).'/index.php');
    exit;

    Note that I tack on '/index.php' because in testing on my localhost I found
    I needed the leading slash since dirname($_SERVE R['PHP_SELF']) was not
    returning a string ending in a slash (ie, no slash after the folder location
    for the web project). So the leading slash HAS to be there for this code to
    work on my localhost development machine. However, when uploaded to the
    regular site, I find that the leading slash should not be there, as I wind
    up redirecting to (for example):



    Now, it happens that the double slash still works (it loads the page),
    although it DOES effect how some of the code executes under a refresh
    (selection of random backgrounds based on cookie settings when a page is
    first reloaded - truly bizaar!).

    Is there an easy way I can recode the redirect so it will work correctly on
    both my localhost development machine and on the web?

    thanks,
    -dg


Working...