Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

relative paths between vhosts posible?

Status
Not open for further replies.

larry1301

Programmer
Jun 11, 2002
3
US
I have two sites running as vhosts (one up, one under development) that share about 50% of their content and php code as well as using the same database and homegrown cart. The sites are running under apache 1.3.20, php 4.1.1 and mysql 3.23.47.

I would like to use indirect file paths to reference content and images from one vhost to the other. No problem for my php includes but my HTML relative paths don't work.

When I try to use a relative path like "../../magazineframes.com/htdocs/images/continue.jpg" from comicframes.com it resolves (per the error log) to "apache/vhosts/comicframes.com/htdocs/magazineframes.com/htdocs/images/continue.jpg" when what I want is "apache/vhosts/htdocs/magazineframes.com/htdocs/images/continue.jpg".

The only thing I can find on this is one web site that says "You can still use relative paths as long as the file is within your own server space". By this I would think using relative paths across vhosts is not possible? Could someone tell me if this is right or if there is anyway to use relative paths across vhosts.

My alternative is to replicate content in both vhosts, which I would much prefer not to do.

BTW, I don't want to combine the sites. One is for custom framing of men's magazines and has about 400 pinup magazine covers. This is an 'R' rated site. The other will be for custom framing of comics and will be a 'G' rated site.

Thanks

 
Hi mate,

I see no way of doing this..

You cannot do it by default because of the security issues that it involves.

Imagine you decided to host a site for someone and they put the paths in a script to display your password files or other files on your machine. Not a good idea..

I realise that this may not matter as only you might have access but I really have no idea how you could bypass this.

Hope this helps Wullie

 
Wullie is right. There is no way for Apache to explicitly reference a file outside the virtual root of a virtual host. This is a good thing. If Microsoft had figured this out, Nimda would not have been such a big deal.

There is a workaround. You could put common content in a third location on the filesystem and have both reference it using the "Alias" directive. That will allow you to map a location in your virtual server URL path to a directory outside the virtual server.


Perfection in engineering does not happen when there is nothing more to add. Rather it happens when there is nothing more to take away.
 
The Alias approach should serve me just fine. After reading the Alias doc it should work well. I like it better than trying to redirect because I can identify easily shared content. I will create Aliases for

Alias /common/ /Alias /CommonImages/ /
for shared code and content and have unique code and content in:

////
I hated the idea of replicating code and content in both places. Too easy to let something get out of synch. This will also make my source code control more efficient as I will change my current VSS projects to a project for each directory.

I appreciate the help.
Thanks,
Larry
 
I think you have grokked the nature of Alias. Perfection in engineering does not happen when there is nothing more to add. Rather it happens when there is nothing more to take away.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top