You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Angie Ahl <an...@vertebrate.co.uk> on 2002/10/05 21:14:09 UTC

[users@httpd] Sethandler a bit overkill for my problem

Hi

This is my first post to the list but I have been using apache for a 
year or so now.

I am trying to resolve an issue affecting myself and several other 
lasso developers with regards to handlers.

Here's the issue in English:

We want all requests for .html and .txt files to go to lasso...
This has been successfully done with the use of addhandler in the 
httpd.conf file

The issue here is that we want all requests to go to lasso, whether a 
file or folder exists or not.

I found using SetHandler in a Directory Directive very effective. So 
effective that it routed all .gif and .jpeg requests to lasso too.

I understand why this is, but I've spent another day in the manual and 
am more confused than when I started (not unusual these days ;)

So does anyone have any answers (or clues), as to how to tell apache to 
route all requests for .html and .txt files to apache whether they or 
their folders exist or not?

It's important that the url/path that was requested is passed to lasso.
I've tried experimenting with the ErrorDocument directive but it 
appears that this is some form of redirect so the originally requested 
url/path is not available to Lasso.

Any tips greatly appreciated.

I did rtfm, several times ;)

TIA

Angie


---------------------------------------------------------------------
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] Sethandler a bit overkill for my problem

Posted by Rich Bowen <rb...@rcbowen.com>.
On Sat, 5 Oct 2002, Angie Ahl wrote:

> Here's a snippet from the httpd.conf file
>
> <VirtualHost *>
>      ServerAdmin angie@vertebrate.co.uk
>      DocumentRoot /Library/WebServer/Documents/angtest/
>      ServerName www.angtest.com
> <LocationMatch \.(html|txt)$>
>      SetHandler lasso-handler
> </LocationMatch>
> </VirtualHost>

OK, perhaps try this:

<LocationMatch ^(.*)\.(html|txt)$>

This is just a theory, and untested, but the additional wildcard on the
front may just force it to match any URL.

-- 
Oh I have slipped the surly bonds of earth
And danced the sky on laughter-silvered wings
 --High Flight (John Gillespie Magee)


---------------------------------------------------------------------
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] Sethandler a bit overkill for my problem

Posted by Angie Ahl <an...@vertebrate.co.uk>.
>> So does anyone have any answers (or clues), as to how to tell apache 
>> to
>> route all requests for .html and .txt files to apache whether they or
>> their folders exist or not?
>
> I think that what you want is:
>
> <LocationMatch \.(html|txt)$>
>     SetHandler foo
> </LocationMatch>
>
> That will ensure that any URL that ends in .html or .txt, whether or 
> not
> the file exists, will be passed to the foo handler.
>
> Is that what you're looking for?
>
> -- 
> Rich Bowen - rbowen@apache.org

Thanks for the response Rich.

That works beautifully if the folder exists and the file doesn't, but 
if neither the file or the folder exist apache chucks it's errorpage 
rather than route the request to lasso.

It's for a content management system, so that we don't have to 
physically create files and folders... All the content is grabbed from 
a MySQL DB... cool when it works right ;)

Here's a snippet from the httpd.conf file

<VirtualHost *>
     ServerAdmin angie@vertebrate.co.uk
     DocumentRoot /Library/WebServer/Documents/angtest/
     ServerName www.angtest.com
<LocationMatch \.(html|txt)$>
     SetHandler lasso-handler
</LocationMatch>
</VirtualHost>

Thanks

Angie


---------------------------------------------------------------------
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] Sethandler a bit overkill for my problem

Posted by Rich Bowen <rb...@rcbowen.com>.
On Sat, 5 Oct 2002, Angie Ahl wrote:

> We want all requests for .html and .txt files to go to lasso...
> This has been successfully done with the use of addhandler in the
> httpd.conf file
>
> The issue here is that we want all requests to go to lasso, whether a
> file or folder exists or not.
>
> So does anyone have any answers (or clues), as to how to tell apache to
> route all requests for .html and .txt files to apache whether they or
> their folders exist or not?

I think that what you want is:

<LocationMatch \.(html|txt)$>
    SetHandler foo
</LocationMatch>

That will ensure that any URL that ends in .html or .txt, whether or not
the file exists, will be passed to the foo handler.

Is that what you're looking for?

-- 
Rich Bowen - rbowen@apache.org
Apache Training - http://CooperMcGregor.com/training/
Come to ApacheCon! - http://www.apachecon.com/


---------------------------------------------------------------------
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] Sethandler a bit overkill for my problem

Posted by Mitch Vincent <mi...@cfact.com>.
I'm not sure what the end result is you're trying to get but
mod_rewrite allows for some cool abilities rules for checking and
redirecting based on the existence of files and directories.

See http://www.engelschall.com/pw/apache/rewriteguide/

One of the examples from that page :

RewriteEngine on
RewriteCond         /your/docroot/dir1/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir1/$1  [L]


Good luck!

> Thanks for the response Rich.
>
> That works beautifully if the folder exists and the file doesn't, but
> if neither the file or the folder exist apache chucks it's errorpage
> rather than route the request to lasso.
>
> It's for a content management system, so that we don't have to
> physically create files and folders... All the content is grabbed from
> a MySQL DB... cool when it works right ;)
>
> Here's a snippet from the httpd.conf file
>
> <VirtualHost *>
>     ServerAdmin angie@vertebrate.co.uk
>     DocumentRoot /Library/WebServer/Documents/angtest/
>     ServerName www.angtest.com
> <LocationMatch \.(html|txt)$>
>     SetHandler lasso-handler
> </LocationMatch>
> </VirtualHost>
>

-Mitch


---------------------------------------------------------------------
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