[Zope] Newbie missing something obvious

R. David Murray bitz@bitdance.com
Mon, 6 Mar 2000 22:28:08 -0500 (EST)


On Mon, 28 Feb 2000 jeffr@odeon.net wrote:
> # Zope configuration maps /Zope/ to the Zope.cgi CGI script
> RewriteEngine on
> RewriteCond %{HTTP:Authorization}  ^(.*)
> RewriteRule ^/Zope(.*) /home/httpd/cgi-bin/Zope.cgi$1 \
> 	[e=HTTP_CGI_AUTHORIZATION:%1,t=application/x-httpd-cgi,l]
> 
> (Note: the RewriteRule is all on one line, without the \.  The trailing /
>  after ^/Zope and after Zope.cgi have been removed per the Gotchas for
>  Zope Beginners HOWTO.)

I hope you got your setup working, Jeff.  Your rewrite rules look
good to me.  But I want to take this opportunity to make a (tested)
alternate suggestion for the rewrite rule.  The above rewrite rule
has the unfortunate feature that URLs like ".../Zopestuff/etc"
match the rewrite rule and get turned into the (not found) path
.../cgi-bin/Zope.cgistuff/etc.  This isn't a problem normally, but
you can perhaps imagine having Zope under a directory with a given
name but wanting another URL with that same name as a prefix
substring to also work (.../news and .../newsimages perhaps?).
I've come up with what I think is a better regexp for use in this
kind of rewrite rule, mostly to avoid the surprise factor of later
having a Zopestuff type URL mysteriously fail to work on me someday:

.../Zope(/.*)?$

which is mapped to

.../cgi-bin/Zope.cgi/$1

The ?$ means that the /<stuff> all the way to the end of the URL is
zero or one time.  So Zope by itself matches, and Zope followed
by a / matches, and Zope followed by /stuff matches, but Zopestuff
does not.

FWIW

--RDM