Re: Using $PATH_INFO as variables (inspired by www.DevShed.com)
| From: | Mike Frazer | Date: | Wed, 30 Jan 2002 20:40:47 +0000 |
| Subject: | Re: Using $PATH_INFO as variables (inspired by www.DevShed.com) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82767@lists.php.net to get a copy of this message | ||
Looks to me like you're dealing with Apache rewrite rules, which goes beyond
the scope of PHP.
Mike Frazer
"Dr.Bob" <stevijn@cliff.ath.cx> wrote in message
news:20020130141651.77728.qmail@pb1.pair.com...
> I have Apache on WinXP.
> That sounds great what you write here, but does this also work when, for
> example, I have that file index.php in www.mycompany.com and when I access
> the URL with www.mycompany.com/projects that he sees it as
> www.mycompany.com/index.php?var=projects ?
> Or does it only work when you go to the root of the site or subdir?
>
> Dr.Bob
>
>
> "Mike Frazer" <mike@invertedmind.com> wrote in message
> news:20020130134533.52202.qmail@pb1.pair.com...
> > What server are you running on? In Apache, if you add any filename to
the
> > DirectoryIndex line, it will display that page from any directory
without
> > specifying the filename. It comes default with pages like index.htm,
> > index.html and index.shtml. If you add, for instance, index.php (some
> > distros have this by default, as well), then you can have it load that
> page
> > by default with no file listed on the address/location bar in our
browser.
> >
> > Mike
> >
> >
> >
> > "Dr.Bob" <dr.bob@zincusa.com> wrote in message
> > news:014501c1a98a$1f0cad30$9a3b40c3@drbob...
> > Hi,
> > I'm trying to figure out how www.devshed.com does what I want to achieve
> > also, this is my point:
> >
> > my main URL (for example) is www.mycompany.com
> > I want the central page about our projects to be found under
> > www.mycompany.com/projects
> > and project LovePeaceAndBananas under
> > www.mycompany.com/projects/LovePeaceAndBananas
> >
> > I already know that this can be achieved by using the $PATH_INFO as
> > variables, to be used in de main file in the root of the site.
> > So far I have my Apache webserver accept files with no extention (index,
> in
> > stead of index.php) to be parsed as PHP. But if I look at the site of
> > DevShed, I don't see them using a file at all! I can't get it to work on
> my
> > local test system to make an URL like
> > www.mycompany.com/projects/LovePeaceAndBananas without the existens of a
> > file called 'projects'.
> > Can anyone tell me their 'trick'? (unfortunately, they don't show their
> page
> > source anymore like they used to do ...)
> >
> > Also, when I try to extract the variabeles from the $PATH_INFO I get
some
> > errors depending whether or not I end with a slash, and I do want to
make
> > this fool prove, so that when a site visitor deletes the slash at the
end,
> > it doesn't result in an error.
> >
> > This is the code I made:
>
> --------------------------------------------------------------------------
> --
> > ---
> > <?php
> > $var_array = explode("/",$PATH_INFO);
> > $words = array_unique ($var_array);
> > $total = count($words);
> > for ($i = 0; $i <= $total; $i++) {
> > echo "variable " . $i . " = " .
> > $var_array[$i]."<br>";
> > }
> > ?>
>
> --------------------------------------------------------------------------
> --
> > ---
> >
> >
> > And when I call this file (localhost/index) like this:
> > http://localhost/index/one/two/three/
> >
> > This is my output:
>
> --------------------------------------------------------------------------
> --
> > ---
> > variable 0 =
> > variable 1 = one
> > variable 2 = two
> > variable 3 = three
> > variable 4 =
>
> --------------------------------------------------------------------------
> --
> > ---
> >
> > Ofcourse I don't need the variable 0 and 4, can someone tell me where
they
> > come from?
> > And, as said above, I get an Undefined Ofset-warning when I don't have a
> > closing slash at the end, how can I protect this?
> >
> > Phew -- a lotta lotta questions here, hope someone can help me to climb
> this
> > PHP-mountain:-)
> > Thanx in advance!
> > Dr.Bob
> >
> >
> >
> >
> >
> >
> >
>
>