Hello, folks.
I'm doing a lot of PHP and Perl programming work and I've found this useful, maybe you'll too 🙂 If so - feel free to mail me.
Ok, here's the deal: we want to make our GET strings look like a directories, so robots, like Altavista can index it properly (as seen on Amazon.com, for example):
Old one:
http://some.host.com/index.php?id=23&id2=344 etc...
New one: http://some.host.com/index.php/id/23/id2/344 etc...
The robot will consider, it is a directory and it will (I hope) index it.
The 'quick-n-dirty' way to do it is adding the following lines to the top of script:
------ cut here -------
<?php
$url_array=explode("/",$PATH_INFO);
if (count($url_array)>1)
{
for ($i=1;$i<count($url_array);$i+=2)
{
$name=$url_array[$i];
$value=$url_array[$i+1];
$str='$'.$name.'="'.$value.'";';
eval($str);
}
}
?>
------ cut here -------
We get all that "name/value" pairs as corresponding variables into the code.
So, instead of wrighting
"script.php?name=value&name2=value2..."
we can just do:
"script.php/name/value/name2/value2..."
And no httpd.conf or .htaccess hacking 🙂
See ya.