You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by David Cumming <Da...@epa.qld.gov.au> on 2002/08/09 07:17:00 UTC

Handler Concept / Question

The basic concept I want to accomplish is to allow for static and dynamic content to be accessed from any url and be transparent to the visitor.

i.e
publish a static page called /foo/bar.htm
have a dynamic page called /foo/foobar.htm

I imagine there are a couple of different ways to do this, such as:

* Set the dynamic page script as the 404 handler, then all it does is determine if the content can be displayed from a database.

OR

* Set ALL requests to filter through my handler, do lookup_uri / lookup_file on it and either return the static content (somehow) or return a dynamic page.


Does anyone have any points of view on whether the script should just be a 404 handler or whether I should set a handler to listen to all requests and have my script determine what to do, or another way to do it?

If I do set my script to answer all requests, how do I tell the webserver to show the static content that exists under the requested url?

All comments welcome.

Dave

David Cumming
Webmaster
Corporate Affairs
Environmental Protection Agency
+61 7 3247 3274

www.env.qld.gov.au


Re: Handler Concept / Question

Posted by pe...@elem.com.
> Does anyone have any points of view on whether the script should just
> be a 404 handler or whether I should set a handler to listen to all
> requests and have my script determine what to do, or another way to do
> it?

Those are both fine.  The 404 handler approach will give slightly better
performance for your static pages.
Other ways people handle this include using an extension that is different
for the dynamic URLs (*.phtml or something), or using Location directives
to map specific URLs to handlers.  The latter is a good way to do it if
you have just a few dynamic URLs or if they can all be grouped in a
certain "directory" like /reports/*.
> If I do set my script to answer all requests, how do I tell the
> webserver to show the static content that exists under the requested
> url?

You have to make the default handler pick it up.  I forget the exact
syntax, but there were some examples posted to the mailing list a while
back.
- Perrin