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.
Printable View
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.
$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.
Thanks Aspen, but I am using apache.
Here is the code I have for test.php:
So if I go to localhost/test.php/555/867-3476?Name="Jen" then it should output this: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]);
?>
But instead I get a 404 error not found.Quote:
Jen's phone number is (555) 867-3476.
If I just go to test.php, I get the following output:
Can anybody tell me what's wrong? Do I need to change something in the php.ini file for this to work?Quote:
0 : 's phone number is () .
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:
See if that works for you.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];
?>
I'll give it a try, thanks.
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
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.
Really? Google no longer accepts those types of URLS? Dang, and I just re-coded so all my stuff would work. :(
It's too bad. Does anyone know how to make it work? Can you give an example that works?Quote:
I would also like to point out that at this time Google will not index url's that are in this manner
Thanks,
John
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