You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2009/05/11 17:18:42 UTC

DO NOT REPLY [Bug 47184] New: Feature request: DirectoryHandler

https://issues.apache.org/bugzilla/show_bug.cgi?id=47184

           Summary: Feature request: DirectoryHandler
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: mod_dir
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: rbowen@apache.org


An awful lot of RewriteRules are written to perform an action that might be
better done with a new directive: DirectoryHandler DirectoryHandler would cause
all (unhandled) requests directed at a particular directory to be handled by a
particular URI or file.

For example:

DirectoryHandler index.php

would replace

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [PT]


This would replace the rewriterule set that comes with virtually every PHP
application out there which maps all requests to an index.php file that
examines the requested URI and does something with it.

Note that this behavior can be half-way simulated using a ErrorDocument 404
directive, but ErrorDocument discards POST data, and so doesn't really do what
we want.

DirectoryHandler could optionally have a flag of some kind that enables or
disables the action performed by those two RewriteCond directives - that is, by
default, DirectoryHandler would catch requests that didn't map to a valid
resource, but perhaps there are cases where you want it to map to that handler
regardless of the presence or absence of files in that location.

There's no urgency on this, it's just a long-standing pet peeve of mine that
I'd like to see handled in 2.4

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #6 from Dan Poirier <po...@pobox.com>  2009-06-16 06:49:17 PST ---
I'm picturing three new directives (there doesn't appear to be a DefaultHandler
directive, and it seems like a useful concept):


DefaultHandler handler-name

Change the default request handler from Apache's built-in "default-handler"
to handler-name.


DefaultMapping index.php

If the request would otherwise result in a 404 response, use the file index.php
to handle it.  The URI is not changed.  This is equivalent to

Action new-handler-name index.php
DefaultHandler new-handler-name

except that no handler named "new-handler-name" is actually defined.

Is "request would otherwise result in a 404 response" the best way to specify
the behavior here?  Maybe it would be better to just describe it as a shortcut
for using Action and DefaultHandler.


SetMapping index.php

Use the file index.php to handle all requests.  The URI is not changed.  This
is equivalent to

Action new-handler-name index.php
SetHandler new-handler-name

except that no handler named "new-handler-name" is actually defined.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #2 from Nick Kew <ni...@webthing.com>  2009-05-11 23:21:34 PST ---
You mean something like DefaultHandler + Action?
(or even DefaultAction, though I think DefaultHandler sounds instinctively
good).

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #4 from Dan Poirier <po...@pobox.com>  2009-06-15 10:09:27 PST ---
It seems to me that this has more to do with mapping than handlers.  So maybe 

DefaultMapping index.php

would be more accurate?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #8 from Dan Poirier <po...@pobox.com>  2009-06-16 10:41:49 PST ---
It occurs to me that replacing the default-handler isn't what we want here,
since that's what would serve the static files for us.  Which I think brings us
back to mapping.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #1 from Owen Winkler <a_...@midnightcircus.com>  2009-05-11 08:49:38 PST ---
This is a great idea.  The Front Controller design pattern is pretty commonly
accepted for web applications.

http://en.wikipedia.org/wiki/Front_controller

It would be great if httpd could support this directly instead of requiring
mod_rewrite.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #9 from Nick Kew <ni...@webthing.com>  2009-06-16 15:00:21 PST ---
Committed fix in r785425 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=785425 ).  It's different to what we discussed yesterday:
should be simpler for users to grok.

Given whose feature request this is, I think I can leave the documentation to
you as already discussed :-)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #3 from Rich Bowen <rb...@apache.org>  2009-05-12 04:32:24 PST ---
(In reply to comment #2)
> You mean something like DefaultHandler + Action?
> (or even DefaultAction, though I think DefaultHandler sounds instinctively
> good).

Yeah, that sounds right. I'm not at all stuck on the name.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184

Rich Bowen <rb...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #14 from Rich Bowen <rb...@apache.org> 2009-09-17 10:38:24 PDT ---
It's in trunk. I'm happy. Thanks, everyone.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184


Dan Poirier <po...@pobox.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |enhancement




-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184

Nick Kew <ni...@webthing.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #10 from Nick Kew <ni...@webthing.com> 2009-09-15 01:27:39 PDT ---
Backport proposal as it stands has been vetoed, and in the absence of input
from the request's originator is getting reversed in trunk.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184

Rich Bowen <rb...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |

--- Comment #11 from Rich Bowen <rb...@apache.org> 2009-09-15 08:19:19 PDT ---
Please forgive my lack of response. I have been generally disconnected for the
last several months. The fix, as committed, seems like The Right Thing to me.
If the disagreement is only about the name, there seem to be many possible
names, and I can't say I care a whole lot. FrontController seems to have an
accepted meaning in the larger world, and makes a lot of sense, but
FallbackHandler also works for me.

On the one hand, I don't feel like an endless debate over The Right Name
benefits our users. On the other hand, we're stuck with it forever. :/

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184

--- Comment #13 from Rich Bowen <rb...@apache.org> 2009-09-16 06:06:00 PDT ---
So, after further discussion on IRC, I think that we agreed on
FallbackResource.

FallbackResource index.php

The above will handle URIs for which there is not a resource found, and so is
ideal for acting as a so-called front controller. This can be set in directory
or .htaccess context.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #7 from Rich Bowen <rb...@apache.org>  2009-06-16 09:01:15 PST ---
I *think* that what you're describing does what I want. The only point of
confusion is your remark about "... would otherwise be a 404." Requests for
existing files (CSS, images, etc) need to end up going to those files, so
there's some "does it exist" checking implied in the feature request. See the
rewriterule implementation in the original ticket. I think that what you're
suggesting will handle that, but I'm not 100% sure.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Re: DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by Nick Kew <ni...@webthing.com>.
bugzilla@apache.org wrote:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=47184
> 
> --- Comment #12 from Will Rowe <wr...@apache.org> 2009-09-15 09:58:13 PDT ---
> It would be good not to add new grammar to the config (e.g. FrontController).
> 
> Default has the issues raised on the dev@ list discussion thread.  Fallback is 
> good.  But Fallback alone seems awfully general and hard for the administrator 
> who comes across it to predict what it does when they first encounter it.  
> 
> Is it a Handler, Action or Mapping?  I found Nick's choice amusing ;-)  Since 
> the syntax and behavior mirror the Action directive (without a first argument, 
> of course) and we do not specify a handler name, it seems that FallbackAction 
> is the most easy-to-comprehend choice.

I'd accept that.  But I was never 100% convinced by any of the
second-word candidates.  What's actually implemented is an
internal URL, and the nearest (very close) analogy is
DirectoryIndex.

DrBacchus and I are both on IRC, where we discussed this a couple
of hours ago.  Why don't you join us?  I'm sure if anyone else were
so concerned about it as to have a problem with us chatting off-list,
they'd have contributed to the subject by now.

-- 
Nick Kew

DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184

--- Comment #12 from Will Rowe <wr...@apache.org> 2009-09-15 09:58:13 PDT ---
It would be good not to add new grammar to the config (e.g. FrontController).

Default has the issues raised on the dev@ list discussion thread.  Fallback is 
good.  But Fallback alone seems awfully general and hard for the administrator 
who comes across it to predict what it does when they first encounter it.  

Is it a Handler, Action or Mapping?  I found Nick's choice amusing ;-)  Since 
the syntax and behavior mirror the Action directive (without a first argument, 
of course) and we do not specify a handler name, it seems that FallbackAction 
is the most easy-to-comprehend choice.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 47184] Feature request: DirectoryHandler

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47184





--- Comment #5 from Rich Bowen <rb...@apache.org>  2009-06-15 10:21:54 PST ---
Just based on preference, I'd rather do

DefaultMapping index.php

than have to do

Action front-handler index.php
DefaultHandler front-handler

You know, one less line.

As far as whether this is a handler or a mapping, I don't care a whole lot. If
this is a semantic question, I'll let you guys work that out. From a
convenience perspective, I'd really rather have one line than two. 

(I think that users tend to find Action confusing - although I'm not entirely
sure why. I think it has to do with defining an alias and then using that alias
later. The same confusion exists for LogFormat and CustomLog.)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org