You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Mike Friedman <fr...@friedo.com> on 2008/07/11 21:25:02 UTC

[users@httpd] PATH_INFO and SCRIPT_NAME for handlers at root level

Greetings!

I'm using Apache 2.2.4 with mod_perl 2.0.3.

I've got a mod_perl handler setup like so, within a vhost:

<Location /myapp>
        SetHandler perl-script
        PerlResponseHandler MyApp::Dispatcher
</Location>

Under this setup, if I navigate to /myapp/foo/bar/baz, I get:

PATH_INFO => /foo/bar/baz
SCRIPT_NAME => /myapp

This makes sense. However, if I then change the Location block from
/myapp to /, the behavior changes:

PATH_INFO => /bar/baz
SCRIPT_NAME => /foo

This breaks my dispatcher, which expects to see everything under the
Location as the PATH_INFO. Is this consistent with how PATH_INFO is
supposed to work, and if so is there a way to make it do what I want?

Thanks for any help!


Mike

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PATH_INFO and SCRIPT_NAME for handlers at root level

Posted by Mike Friedman <fr...@friedo.com>.
Thanks, Torsten. It looks like that approach will work perfectly for
what I need.


Mike


On Sat, Jul 12, 2008 at 10:26 AM, Torsten Foertsch
<to...@gmx.net> wrote:
> On Fri 11 Jul 2008, Mike Friedman wrote:
>> I've got a mod_perl handler setup like so, within a vhost:
>>
>> <Location /myapp>
>>         SetHandler perl-script
>>         PerlResponseHandler MyApp::Dispatcher
>> </Location>
>>
>> Under this setup, if I navigate to /myapp/foo/bar/baz, I get:
>>
>> PATH_INFO => /foo/bar/baz
>> SCRIPT_NAME => /myapp
>>
>> This makes sense. However, if I then change the Location block from
>> /myapp to /, the behavior changes:
>>
>> PATH_INFO => /bar/baz
>> SCRIPT_NAME => /foo
>
> Path_info determination depends on the layout of files and directories on your
> filesystem. I'd advise against using it in anything like a dispatcher. Just
> for fun try to create a regular file /myapp/foo/bar in your docroot and use
> your first setup. You'll see PATH_INFO=/baz.
>
> Instead use $r->location and $r->uri to compute a version of path-info by
> yourself. Something like that:
>
>  $pi=$r->uri;
>  $loc=$r->location;
>  $pi=~s/^\E$loc\Q//;
>
> Torsten
>
> --
> Need professional mod_perl support?
> Just hire me: torsten.foertsch@gmx.net
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] PATH_INFO and SCRIPT_NAME for handlers at root level

Posted by Torsten Foertsch <to...@gmx.net>.
On Fri 11 Jul 2008, Mike Friedman wrote:
> I've got a mod_perl handler setup like so, within a vhost:
>
> <Location /myapp>
>         SetHandler perl-script
>         PerlResponseHandler MyApp::Dispatcher
> </Location>
>
> Under this setup, if I navigate to /myapp/foo/bar/baz, I get:
>
> PATH_INFO => /foo/bar/baz
> SCRIPT_NAME => /myapp
>
> This makes sense. However, if I then change the Location block from
> /myapp to /, the behavior changes:
>
> PATH_INFO => /bar/baz
> SCRIPT_NAME => /foo

Path_info determination depends on the layout of files and directories on your 
filesystem. I'd advise against using it in anything like a dispatcher. Just 
for fun try to create a regular file /myapp/foo/bar in your docroot and use 
your first setup. You'll see PATH_INFO=/baz.

Instead use $r->location and $r->uri to compute a version of path-info by 
yourself. Something like that:

  $pi=$r->uri;
  $loc=$r->location;
  $pi=~s/^\E$loc\Q//;

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org