[Zope] Zope w/ FastCGI / mod_rewrite

Brian Takashi Hooper brian@garage.co.jp
Wed, 16 Feb 2000 15:26:28 +0900


Hi all,

I'm setting up Zope to use FastCGI w/ Apache, I followed the How-to by
kedai on zope.org and got most of the way, however I still have a few
questions:

1. I want to serve my site with the root URL as FastCGI but be able to
have absolute URLs sans hostname (i.e. <a href="/images/foo.gif">)
resolve properly... if I just use a simple rewrite rule like:

...
RewriteRule ^/(.*) /fcgi/$1 [PT]

then the top page works, but all the links off this page are based off
of <base href>, which gets set to something like http://myhost/fcgi.

Base href seems to be inferred by doing some stuff with the SERVER_URL
and SCRIPT_NAME environment variables; SCRIPT_NAME gets passed from pcgi
set to my FastCGI script name, /fcgi.  Is there a good way within the
CGI protocol that I can tell Zope that it should ignore SCRIPT_NAME when
deciding the base href of my site, since I'm rewriting the URL so that
stuff without the /fcgi will get there?  

For now, I just added a hack to HTTPRequest.py, but as you can imagine,
it's ugly :-(.  What's the RWTDT right way to do this?


2. I also would like to preserve ScriptAlias and Alias directories on
the Apache side more nicely - right now it seems like if I line up some
additional rewrite rules for /cgi-bin/, etc. before the fcgi rewrite
rule, like:

RewriteRule ^/cgi-bin/(.*) /cgi-bin/$1 [L,PT]
RewriteRule ^/(.*) /fcgi/$1 [PT]

the annoying thing is that sometimes URLs end up passing through the
Rewrite engine twice as well  (explanation: a Pass-Through is necessary
in order to get mod_alias to handle /cgi-bin as a ScriptAlias-ed
directory; however, if there's any URL left at that point, i.e.
/cgi-bin/myscript/foo/, then /foo/ travels through the Rewrite engine
again, according to the logs).  This is more of an Apache question than
a Zope question - however I think this is also of interest to others who
might want to integrate Zope into their existing setup, so if anyone has
any suggestions... :-) !


Brian Hooper