On Tue, Mar 23, 2010 at 11:01 AM, Deron Meranda <[email protected]> wrote:
> I'm trying to mix both static content (or content from other types
> of handlers) with mod_wsgi handlers. I don't want to partition
> things out into separate directories (like /static and /wsgiscripts),
> but want them all to intermingle.
I kind of got this working, I think, using mod_rewrite rules. It's a
bit ugly, and I had to do things slightly different than what's in
the documentation wiki (ConfigurationGuidelines).
Here's what I had to add to my VirtualHost (I'm not done testing
all cases yet, but I think this works):
<VirtualHost ...
.... other apache directives ....
<IfModule wsgi_module>
DirectoryIndex index.wsgi
WSGI* -- .... other mod_wsgi directives ....
AddHandler wsgi-script .wsgi
RewriteEngine On
RewriteLog /var/log/httpd/rewrite.log
RewriteLogLevel 4
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.wsgi/$1 [QSA,PT,L]
</IfModule>
</VirtualHost>
Now, if a file exists at the URL, then it is served normally as
Apache usually does. But if there is no file, then a single
site-wide wsgi script is called to handle it. Which is what
I want. I want wsgi to get anything that would have normally
resulted in a 404.
(Note that I could probably do away with the DirectoryIndex
part if I added another and'ed condition with !-d ???)
For some reason I had to prepend %{DOCUMENT_ROOT}/
to the rewrite condition, because %{REQUEST_FILENAME} was
a relative path from the document root and the !-f condition
requires an absolute path. (Setting RewriteLogLevel to 4 let
me finally debug that)
So this will suffice, but it still seems much messier than it was
under mod_python. Plus I'd like to be able to do this on a
per-directory level rather than at the site/virtual-host level,
as well as being able to override any of this in local .htaccess
files -- I'm not sure yet if I can do that using this technique.
It still might be nice to have something similar to PythonHandler,
where I could set the wsgi script be something other than the URL.
--
Deron Meranda
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en.