[Zope] apache rewrite rules redux

Sascha Welter zopelist at betabug.ch
Thu May 25 03:08:56 EDT 2006


(Wed, May 24, 2006 at 12:00:09PM -0400) zope-request at zope.org wrote/schrieb/egrapse:
> From: "David Bear" <dwbear75 at gmail.com>

> # see http://betabug.ch/zope/witch
> RewriteRule ^/z2$ http://127.0.0.1:9080/VirtualHostBase/\
> https/%SERVER_NAME}:80/VirtualHostRoot/_vh_z2/ [L,P]
> 
> RewriteRule ^/z2/(.*) http://127.0.0.1:9080/VirtualHostBase/\
> https/%{SERVER_NAME}:80/VirtualHostRoot/_vh_z2/$1 [L,P]
                       ^^
Just telling the witch to use "https" isn't enough, you have to tell it
the port too (usually 443). 

This isn't the most obvious thing from th form, but it should be a cluee
that the port doesn't change when you select https.

> I also found the following rule from scanning through zope-list postings, to
> force any logon authentication requests to go over https. However, since the
> above rules fail, the following does nothing.
> 
> RewriteRule ^/login_form(.*) https://%{SERVER_NAME}/login_form$1 [NE,L]

This is a redirect and once your https-rewriterule works, it should too.

> From: Chris Withers <chris at simplistix.co.uk>
> In both cases, I see no need for two rules, just the one should suffice:
> 
> RewriteRule ^/z2(.*) http://127.0.0.1:9080/VirtualHostBase/\
> http/%{SERVER_NAME}:80/VirtualHostRoot/_vh_z2$1 [L,P]

Yes, that will work too, unless of course you happen to have a URL that
goes something like http://www.host.tld/z2thisisnotzope/index.html and apache
will happily rewrite it for you, resulting in a 404.

The two rules of the witch could likely be rewritten to one, but two
rules cover the two possibilities easy in a form that humans can grasp:
Either the URL ends there, or else it has a slash and then as much as
there is.

Regards,

Sascha



More information about the Zope mailing list