[Zope] Why base href?
Phillip J. Eby
pje@telecommunity.com
Thu, 10 Jun 1999 14:07:10 -0500
At 08:21 PM 6/10/99 +0200, Christian Andreassen wrote:
>For some reason, Zope sometimes add a <base href=> tag in HTML documents.
>When Zope is used in combination with Apache and Apache is configured to
>rewrite incoming requests to a Zope folder that is not the root folder, this
>will cause trouble if there are any relative URLs in the documents. The way
>Zope determines the URL in the base href in combination with the way Apache
>rewriting works will often, after clicking around the site a few times, lead
>to something like www.mysite.org/mysiteroot/mysiteroot/mysiteroot/somedoc in
>the address line of the browser. It looks ugly, it tricks the browser from
>caching documents properly and visited links will look unvisited.
>
>Does anybody know why <base href> is inserted automatically? Any tricks for
>turning it off?
Zope adds a base tag whenever an implicit method is being called, such as
index_html or a method referenced by a :method field. This is so that
relative URL's in such methods will be relative to the right place.
There is a RESPONSE.setBase() method that can be called to change the base;
but you'll need to know what the base should be, or else you'll have to
forego all use of implicit methods.
There may be a simpler solution, however. ZPublisher determines the base
using the SERVER_URL and SCRIPT_NAME environment variables. If you can
rewrite those from Apache to match the way Zope looks to the rest of the
world, then you're all set. If that can't be done, perhaps a patch to
allow a different variable to override this (along the lines of
HTTP_CGI_AUTHORIZATION) is in order.