Forum Moderators: phranque
i have seen on many sites people use URLs like
www.domain.com/category/itemid/color
and then they somehow translate it to read data from database.
e.g this URL www.domain.com/category/index.php?itemid=10&color=red may look like
www.domain.com/category/10/red
now please help me to find the answers to the following questions
1 - how to make hyperlink for such URLs? for example if i do something like
<a href="/category/10/red" > link </a>
then it will show me HTTP 404 error as it will read '10' and 'red' as folders ...
2 - how to fetch needed data from the URL like www.domain.com/category/10/red and store in variables to use in dynamic queries.
please reply..
thanks
e.g this URL www.domain.com/category/index.php?itemid=10&color=red may look likewww.domain.com/category/10/red
If it looks instead like www.domain.com/category/index.php/10/red
then apache is capable of recognizing that "index.php" is a php program.
If so, then $_SERVER['PATH_INFO'] would contain /10/red
You could do: list($scrap, $itemid, $color) = spliti("/", $_SERVER['PATH_INFO']);
($scrap is to catch the null string before the first delimiter "/".)
I have not found 'PATH_INFO" documented in the php manual and am curious why php never documented it.
I had one occasion when 'PATH_INFO' was not configured to work on some server but I don't know how that was addressed and fixed. If anyone knows about this configuration, I would be interested.
[edited by: lmo4103 at 12:50 pm (utc) on Oct. 4, 2006]
This can be combined, to a greater or lesser degree depending on your preference, with the method described above by lmo4103.
Jim