Most efficient use of url rewriting and virtual host monster.
Hi List, I have a problem at the moment, that is mostly cosmetic, but quite annoying. I host a few domains on a single zope instance, in different folders. For example, domain xyz is mapped to: ip/folder/xyz. So far, I have not really grasped the virtual host root concept. I use the absolute_url method quite a lot in my scripts, and because of these two things, I end up with lots of urls that look like: http://ip/folder/xyz/folder/xyz/folder/xyz/folder/xyz/someScript I guess what I'm really looking for is a good explanation for virtual host root, as well some insight in how zope generates urls. I hope that was clear enough, it's been a while since I looked at these things. Thanks, Alec Munro
On Wed, 2003-11-12 at 08:54, Alec Munro wrote:
I guess what I'm really looking for is a good explanation for virtual host root, as well some insight in how zope generates urls.
All you need is to create a VHM instance. It doesn't actually matter what you call it. Let's say domain_name.com is hosted from here in the Zope hierarchy: /sites/domain_name Put this in domain_name's virtual host block in Apache (one line): RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/www.domain_name.com:80/sites/doma... [L,P] Reload Apache and you should be good to go. HTH, Dylan
Dylan Reinhardt wrote:
On Wed, 2003-11-12 at 08:54, Alec Munro wrote:
I guess what I'm really looking for is a good explanation for virtual host root, as well some insight in how zope generates urls.
All you need is to create a VHM instance. It doesn't actually matter what you call it.
Let's say domain_name.com is hosted from here in the Zope hierarchy:
/sites/domain_name
Put this in domain_name's virtual host block in Apache (one line):
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/www.domain_name.com:80/sites/doma... [L,P]
Reload Apache and you should be good to go.
HTH,
Dylan
Thanks for the response, but I have more specific problems than simply getting it working. The main problem I seem to have at the moment is that when I do the above, so that I have the Virtual Host Root set up the way I want it, then restrictedTraverse stops working. I use it in many places, and when I have the VHR set, it seems like it works from the root of the zope instance itself, so if I am traversing ("/HTML/somePage") it will give me a KeyError if I don't have this in the root of my zope instance. What I assume is happening is that when I use restrictedTraverse on a string that came from an absolute_url, then the url is truncated when I'm using a VHM, and I get "/HTML/somePage" instead of "/folder/xyz/HTML/somePage". Is there some way I can adapt restrictedTraverse to root it in a certain directory? Or will I need to prefix all my absolute_urls with the path to the parent folder. Or is there a function like absolute_url that will disregard the VHR? I know that was long, so thanks for reading. Thanks, Alec Munro
Alec Munro wrote:
the url is truncated when I'm using a VHM, and I get "/HTML/somePage" instead of "/folder/xyz/HTML/somePage". Is there some way I can adapt restrictedTraverse to root it in a certain directory?
Ah, you want getPhysicalPath(), not absolute_url(), since restrictedTraverse operates on paths, not URLs. Cheers, Evan @ 4-am
Alec Munro wrote:
Hi List,
I have a problem at the moment, that is mostly cosmetic, but quite annoying.
you should allways use absolute urls instead of relative urls in Zope. It is also much more efficient for caching files in the browser etc. regards Max M
Alec Munro wrote at 2003-11-12 12:54 -0400:
I have a problem at the moment, that is mostly cosmetic, but quite annoying. I host a few domains on a single zope instance, in different folders. For example, domain xyz is mapped to: ip/folder/xyz. So far, I have not really grasped the virtual host root concept. I use the absolute_url method quite a lot in my scripts, and because of these two things, I end up with lots of urls that look like:
http://ip/folder/xyz/folder/xyz/folder/xyz/folder/xyz/someScript
I guess what I'm really looking for is a good explanation for virtual host root, as well some insight in how zope generates urls.
Did you read the "Readme" of a "VHM" instance? Do or redo it... -- Dieter
participants (5)
-
Alec Munro -
Dieter Maurer -
Dylan Reinhardt -
Evan Simpson -
Max M