SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: $path_info

  1. #1
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $path_info

    Does the $PATH_INFO variable work on windows? I just get
    404 errors if I add /whatever to the URL. Can anybody tell me why? Thanks.
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $PATH_INFO works with Apache, which is a popular free web server.

    On windows you're probably using IIS or PWS for your web server.

    Now while apache (apache.org) is made for Linux/Unix, you can install it on windows, which is what you must do if you need to use the $PATH_INFO variable.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Aspen, but I am using apache.

    Here is the code I have for test.php:
    PHP Code:
    <?PHP
    $argv 
    split("/"$PATH_INFO); 

    while (list(
    $key,$val) = each($argv) ) { 
    printf("%s : %s
    "
    $key$val); 


    printf("%s's phone number is (%s) %s.

    "

    $name$argv[1], $argv[2]); 
    ?>
    So if I go to localhost/test.php/555/867-3476?Name="Jen" then it should output this:
    Jen's phone number is (555) 867-3476.
    But instead I get a 404 error not found.

    If I just go to test.php, I get the following output:
    0 : 's phone number is () .
    Can anybody tell me what's wrong? Do I need to change something in the php.ini file for this to work?
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  4. #4
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think that it is in that last question mark, because then it looks for, essentially this:

    c:\home\www\test.php\555\867-3476?Name=Jen

    Because of your last question mark it looks for the dir test.php, 555, and 867-3476... see? If that dir were to exist and it contained an index.php file apache would call this page up: localhost/test.php/555/867-3476/?Name=Jen. Are you following me? When you use the search engine safe URLs then you need to use them ALL of the way through.

    Try this instead:

    PHP Code:
    <?PHP
    $argv 
    split("/"$PATH_INFO);

    printf("%s's Phone Number Is (%s) %s"$argv[3], $argv[1], $argv[2]);

    // OR
    echo $argv[3] ."'s Phone Number Is (".$argv[1].")".$argv[2];
    ?>
    See if that works for you.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  5. #5
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll give it a try, thanks.
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  6. #6
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would also like to point out that at this time Google will not index url's that are in this manner

    script.extension/variable/variable/variable
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  7. #7
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that's not a problem. I'm making an editing program in an admin section.

    So it will be edit.php/main.php which will edit main.php
    It still didn't work though. I use Xitami, so that might be why.
    Love it? Hate it? Helpful? Useless?
    Use the rate button to let me know what you think of my post!

  8. #8
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really? Google no longer accepts those types of URLS? Dang, and I just re-coded so all my stuff would work.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  9. #9
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would also like to point out that at this time Google will not index url's that are in this manner
    It's too bad. Does anyone know how to make it work? Can you give an example that works?

    Thanks,
    John

  10. #10
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're making an admin section why even bother? Afterall this method is only used to get search engines who don't index query strings to index your pages.

    As for another way to do it, you can use a .htaccess error handling hack to do it.

    There are a few articles on php builder on how to do it.

    I also just switched my site to using this method because I got tired of waiting around for google to fix their spider and I Wasn't going to kiss all that traffic off.

    Of course if you do use this method you can kiss your error logs goodbye as every page will be logged as an error by your server.

    http://www.phpbuilder.com/columns/tim19990117.php3
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums


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
  •