SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    backslash in URL

    There is the following line
    PHP Code:
    $location $protocol .$_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) .'/person_list.php'
    in index.php for an application i am using to learn PHP.

    I have my own WAMP setup with all the individual projects i am working on setup as virtual host. So this script is actually located in
    c:\www\sampleapplication.dev\public_html\index.php.
    Hence http://www.sampleapplication.dev is supposed to launce the page. However instead the turns to
    Code:
    http://www.sampleapplication.dev\/person_list.php
    which gives

    Code:
    Address Not Found        
    
    Firefox can't find the server at www.sampleapplication.dev\.
    The browser could not find the host server for the provided address.
    
        * Did you make a mistake when typing the domain? (e.g. "ww.mozilla.org" instead of "www.mozilla.org")
        * Are you certain this domain address exists?  Its registration may have expired.
        * Are you unable to browse other sites?  Check your network connection and DNS server settings.
        * Is your computer or network protected by a firewall or proxy?  Incorrect settings can interfere with Web browsing.
    What could be the cause as other scripts without
    Code:
    $location = $protocol .$_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) .'/person_list.php';
    launch OK.

  2. #2
    SitePoint Member TheDarkFool's Avatar
    Join Date
    Jun 2008
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had a similar issue a few days agon, and this was my code that was causing it, and also the way i fixed it is also shown by the comments.

    <?php
    function redirect($url) {
    if (!headers_sent()) {
    header('Location: http://' . $_SERVER['HTTP_HOST'] .
    // By adding stripslashes around the driectory name, i fixed the problematic backslash IE; http://localhost\/index.php
    stripslashes(dirname($_SERVER['PHP_SELF'])) . '/' . $url);
    } else {
    die('Could not redirect; Headers already sent (output).');
    }
    }
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •