RE: [PHP] Replacing ? and & with / in URLS
| From: | Nold, Mark | Date: | Thu, 07 Dec 2000 00:24:06 +0000 |
| Subject: | RE: [PHP] Replacing ? and & with / in URLS | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-29006@lists.php.net to get a copy of this message | ||
----------------------------------------------------------------------------
-----------------
Disclaimer: The information contained in this email is intended only for the
use of the person(s) to whom it is addressed and may be confidential or
contain legally privileged information. If you are not the intended
recipient you are hereby notified that any perusal, use, distribution,
copying or disclosure is strictly prohibited. If you have received this
email in error please immediately advise us by return email at
postmaster@normandy.com.au and delete the email document without making a
copy.
----------------------------------------------------------------------------
-----------------
What im trying to do is have a repository of files outside to web root.
Which a user can access via a URL (with no query string). It also has to
work via Apache + IIS on un*x and win32, CGI and Module versions of PHP....
Currently i have a directory set up with no files it in but an error handler
for file not found (can set up in Apache and IIS) that simply finds the
file, checks the users security (via a session based security module) and
then reads the file or sends a no access error page.
The users simple access http://www.mysite.com/documents/direct/docid1234.pdf
and docid1234.pdf will be delivered. Why do this? Search engines and the it
makes it a lot easier for people to think in files rather than scripts and
params. It also means i can use file uploads etc and have a web server
independent based security model.
This works pretty fine except with PHP CGI it does send a "file not found"
to the user... you can over-write this (header(Status: OK) i think) in the
PHP module version but not in CGI, this makes things confusing for some
versions of acrobat and some proxy's but others it works fine with....
What id rather do is have direct as a script and docid1234.pdf be a variable
so that the file actually exists.
I'll see if i can find a dirctory specific forcetype in IIS.
mn
Mark Nold
markn@enspace.com <mailto:markn@enspace.com>
Senior Consultant
Change is inevitable, except from vending machines.
-----Original Message-----
From: Anthony Martin [mailto:Anthony@TRAMS.com]
Sent: Thursday, December 07, 2000 3:51 AM
To: 'Cynic'; Richard Lynch; php-general@lists.php.net; Nold, Mark
Subject: RE: [PHP] Replacing ? and & with / in URLS
Why would one do this? Content-Disposition prevents the need for fake
filenames. I guess the only thing I know of would be to make search engines
happy. Any other reason? Just curious.
Anthony
-----Original Message-----
From: Cynic [mailto:cynic@mail.cz]
Sent: Wednesday, December 06, 2000 11:51 AM
To: Richard Lynch; php-general@lists.php.net; Nold, Mark
Subject: Re: [PHP] Replacing ? and & with / in URLS
I used this quite some time ago with CGI PHP, and it worked.
Actually, you don't have to use mod_rewrite to achieve this.
ForceType is enough, since Apache uses the longest part of
a URL that maps to a file on the underlying filesystem.
E. g.:
say you have the DocumentRoot in /www, and you have a PHP
script named "script" in /www/foo/bar, you can put (this is
just one of several possible ways)
<Location /foo/bar/script>
ForceType application/x-httpd-php
</Location>
in your httpd.conf. Then, when Apache recieves a URL like
http://www.server.tld/foo/bar/script/var1/somevalue/var2/othervalue
it invokes /www/foo/bar/script, and you can then extract the
variables from $HTTP_SERVER_VARS["QUERY_STRING"] (assuming
there is "S" somewhere in the value of the variables_order
directive, either in php.ini or in httpd.conf, but that's
another story).
Let me try...
Well, it apparently doesn't work anymore.
http://www.server.tld/foo/bar/script serves the
script fine,
however when I add something to the URI, I get an empty file,
and
"GET /foo/bar/script/var1/somevalue/var2/othervalue HTTP/1.1" 200 5
in the Apache access log... I don't know the internals, but
this looks like a bug somewhere...
Ok, this is really interesting.
I'm trying something like http://www.server.tld/foo/bar/script.
With the <Files ...> directive, Apache outputs the file without
handing it over to PHP to parse it.
access log: 200 76 (correct length)
With <Directory ...> I get an empty file.
access log: 200 5
With <Location ...> tried again I get an empty file!
access log: 200 5
This is really weird, since the last method worked when i tried
it about ten minutes ago...
However, I'm not sure who's to blame, since I use DSO PHP 4.0.4-dev
and Apache 1.3.15-dev on NT5 SP1.
I'm going to try newest Apache and PHP, and if that doesn't help,
latest Apache and PHP releases.
Nevertheless, this thing worked for me at least with Apache 1.3.12
and one of PHP 4.0 betas...
At 05:47 6.12. 2000, Richard Lynch wrote the following:
--------------------------------------------------------------
>It involves the Rewrite rule/module to Apache (http://apache.org) and then
>PHP uses $argc/$argv or $PATH_INFO to figure out the args.
>
>I don't see why it wouldn't work with CGI, but never tried it.
>
>Zeev (?) has a tutorial out there somewhere about it, but I dunno if that's
>the one you're referencing or not... On Devshed or Weberdev or PHPBuilder
>maybe?
>
>----- Original Message -----
>From: "Nold, Mark" <Mark.Nold@normandy.com.au>
>Newsgroups: php.general
>Sent: Tuesday, December 05, 2000 10:18 PM
>Subject: [PHP] Replacing ? and & with / in URLS
>
>
>>
--------------------------------------------------------------------------
>--
>> -----------------
>> Disclaimer: The information contained in this email is intended only for
>the
>> use of the person(s) to whom it is addressed and may be confidential or
>> contain legally privileged information. If you are not the intended
>> recipient you are hereby notified that any perusal, use, distribution,
>> copying or disclosure is strictly prohibited. If you have received this
>> email in error please immediately advise us by return email at
>> postmaster@normandy.com.au and delete the email document without making a
>> copy.
>>
--------------------------------------------------------------------------
>--
>> -----------------
>> Hi,
>>
>> Ive seen several references to the fact that you can exchange ? and & in
>> URLS (ie: GET) with /
>>
>>
>> http://www.yourserver.com/db/script.php3?radius=3&user=6&people=TRUE
>> will become this:
>>
>> http://www.yourserver.com/db/script.php3/radius/3/user/6/people/TRUE
>>
>> (These are from
>>
>> http://marc.theaimsgroup.com/?l=php-general&m=94961873902307&w=2
>> )
>>
>>
>> I'm having problems with this on Apache with PHP as a CGI, where i get an
>> Internal Server error all the time. Any ideas?
>>
>> Any idea what this functionaly is called? Is it a PHP function? an Apache
>> function?
>>
>> Thanks,
>>
>> mn
>>
>>
>> Mark Nold
>> markn@enspace.com
>> Senior Consultant
>>
>> Change is inevitable, except from vending machines.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>> For additional commands, e-mail: php-general-help@lists.php.net
>> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz
ICQ: 2808 2505
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net