I've just spent far too long wrestling with the VHM, but I've finally sorted it. However, I don't understand exactly what was going on, and I'd love an explanation. I was trying to get requests for http://www.foo.com/Bar/rest/of/url to look in http://localhost:8080/demo/Bar/SomeFolder/rest/of/url and I was using RewriteRule ^/([^/]+)/?(.*) http://localhost:9080/VirtualHostBase/http/www.foo.com:80/demo/$1/SomeFolder... [P] to do this. It worked, but absolute_url was resolving to http://www.foo.com/rest/of/url. In order to fix absolute_url, I found after much hair-tearing that the following worked: RewriteRule ^/([^/]+)/?(.*) http://localhost:9080/VirtualHostBase/http/www.foo.com:80/demo/$1/SomeFolder... [P] Why did the second version (with _vh_) work, but the first not? Cheers, seb
From: "seb bacon" <seb@jamkit.com>
RewriteRule ^/([^/]+)/?(.*) http://localhost:9080/VirtualHostBase/http/www.foo.com:80/demo/$1/SomeFo lder/VirtualHostRoot/$1/$2 [P]
RewriteRule ^/([^/]+)/?(.*) http://localhost:9080/VirtualHostBase/http/www.foo.com:80/demo/$1/SomeFo lder/VirtualHostRoot/_vh_$1/$2 [P]
Why did the second version (with _vh_) work, but the first not?
Because 'VirtualHostRoot' removes all of the path up to that point from the URL, and does this by remembering the absolute_url() of the object found at that step. In your first version, putting '$1' in the path a second time complicated acquisition a little, but does nothing for your URL. I added the '_vh_' behavior to support people who map a domain subdirectory into a Zope's root. Yours is an intermediate case, mapping a domain subdirectory into a Zope subfolder. Path segments like '_vh_XXX', right after the 'VirtualHostRoot', add to the URL path without trying to find a Zope object named 'XXX'. Cheers, Evan @ 4-am & Zope
participants (2)
-
Evan Simpson -
seb bacon