thanks
You don't need PHP for this - it's straight html and possibly apache
configuration (mod_rewrite).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Say you have the page http://nl.php.net/manual/en/index.php. A request to
http://nl.php.net/manual/en/index.php/any.file.name will also be served
by index.php. In this example, it does not change the page, but the PHP
file may parse the URL and decide to serve something else when the URL is
different.
Anybody knows what this feature is called or why this works like this?
Yes, as Jerry says above that's apache's mod_rewrite module.
It's a system that uses regular expressions to pattern match and convert
the URLs you receive in a GET requests into the URLs you actually want.
You specify rewrite directives in you apache config file OR (for
individual users) in htaccess files.
By rewriting the URLS you can change paths into variables e.g.
You receive http://www.poo.poo/images/badgers
and mod_rewrite could change that into:
http://www.poo.poo/imagescript.php?type=badgers
Thereby mapping paths to PHP scripts and variables.
The reference documentation is quite terrifying considering the simple
use cases most people have so I'm not sure I recommend reading and
regular expressions(regex) can take quite a while to get the hang of too
so be prepared to spend a few evenings mastering it! Some useful
examples can be found here:
http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
Roger Heathcote.
No it's not - it's how apache works **without** mod_rewrite.
I've no idea if this is an apache-specific feature or if other
webservers allow this too.
In order to make use of this you need to parse the contents of
$_SERVER['PHP_SELF']
C.
ok thanks to all :)
Check again. mod_rewrite needs to be involved. Otherwise your script
will never get control - the user will get a 404 Not Found instead.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Not in my experience. The server seems to redirect requests to a "subdir"
of the PHP file to the PHP file itself.
Appearantly, this works not only on my server but on other servers too:
http://nl.php.net/manual/en/index.php/any.file.name
http://www.friendster.com/widgetdirectory.php/any.file.name
http://www.colemaninstitute.org/overview.php/any-file-name
Here, I appended any-file-name, but that gives the same page as without
it and not a 404 Not Found.
Besides, www.colemaninstitute.org seems to be running IIS.
Then the server is set up to serve that page instead of a 404 Not Found.
Not really a good idea, IMHO.
Actually he's right, although it sounds like mod rewrite I just tried:
http://www.php.net/downloads.php/test
and it served up exactly the same page as:
http://www.php.net/downloads.php
How odd.
I'm guessing it's a PHP/apache thing rather than an plain apache thing
as: http://httpd.apache.org/index.html/test gives a 404.
My best guess is that, seeing a script in the path apache just tosses
everything to the right of the .php to the PPH interpreter.
Would be interested to see if it works the same was on IIS though.
Regards,
Roger.
> Actually he's right, although it sounds like mod rewrite I just tried:
>
> http://www.php.net/downloads.php/test
>
> and it served up exactly the same page as:
>
> http://www.php.net/downloads.php
>
> How odd.
Nothing odd about it at all. PATH_INFO has been around for as long as
CGI scripts have been.
> I'm guessing it's a PHP/apache thing
No, PATH_INFO predates both PHP and Apache.
> Would be interested to see if it works the same was on IIS though.
PATH_INFO works the same way on any standards-compliant server.
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
So this behaviour happens even on apache without PHP then??
Roger.
Yes, of course. PATH_INFO is a standard CGI variable, available on any
server in any language:
<http://hoohoo.ncsa.uiuc.edu/cgi/env.html>
"These environment variables are set when the server executes the
gateway program."
So, to clarify, when you have any scripting/CGI invoked by the URL the
server will eat the rest of the URL and give it to the script/CGI in
this PATH_INFO variable.
When it doesn't (i.e. plain .html files) it'll just throw a 404.
Is this correct?
Sorry if I sound naive but I want to make sure I'm understanding this
properly.
BTW: When I said 'apache without PHP' what I meant was 'apache with no
scripting running, CGI or otherwise'. My bad. I guess I should have been
clearer about that.
Thanks for the insight,
Roger.
> Sherm Pendley wrote:
>> r0g <aioe...@technicalbloke.com> writes:
>>
>>> So this behaviour happens even on apache without PHP then??
>>
>> Yes, of course. PATH_INFO is a standard CGI variable, available on any
>> server in any language:
>>
>> <http://hoohoo.ncsa.uiuc.edu/cgi/env.html>
>
> "These environment variables are set when the server executes the
> gateway program."
>
> So, to clarify, when you have any scripting/CGI invoked by the URL the
> server will eat the rest of the URL and give it to the script/CGI in
> this PATH_INFO variable.
Yes, exactly. Suppose you have a URL like this:
<http://foo.invalid/index.php/bar/baz/qux>
Now, supposing your base HTML directory is /home/html, when index.php
is executed the value of PATH_INFO will be '/bar/baz/qux', and that of
PATH_TRANSLATED will be '/home/html/bar/baz/qux'.
> When it doesn't (i.e. plain .html files) it'll just throw a 404.
>
> Is this correct?
Right. CGI variables aren't passed to static content, because there
would be no point in doing so - static content, by definition, would
not be able to use them anyway.
but i have other request, how to i use a char # in file htacces if is
comment ?
example on really site:
http://www.new.facebook.com/home.php
http://www.new.facebook.com/home.php#/notifications.php
ecc . . .
cobra90nj
Try alt.apache.configuration. This is NOT a PHP question.
>but i have other request, how to i usa a char # in file htacces if is
>comment ?
The # separates the URL from the fragment identifier. The server will
never see it. If you want that char to appear in your URLs, you have to
encode it.
>example on really site:
>
>http://www.new.facebook.com/home.php
>
>http://www.new.facebook.com/home.php#/notifications.php
Technically it's the same URL. The latter just contains a (invalid)
fragment identifier, which is handled by the browser.
Micha
> >http://www.new.facebook.com/home.php
>
> >http://www.new.facebook.com/home.php#/notifications.php
>
> Technically it's the same URL. The latter just contains a (invalid)
> fragment identifier, which is handled by the browser.
RFC 3986 allows the fragment identifier </notifications.php> and HTML
allows the (a element) name attribute value "/
notifications.php" (although the same value for the id attribute would
be invalid).
--
Jock
Yes. See my reply in the other thread about the names on form controls.
Same thing.
Micha