Gossamer Forum
Home : General : Perl Programming :

including file from outside virtual host

Quote Reply
including file from outside virtual host
I am working on a large project that envolves using the same content on different virtual hosts (all on the same server). My problem is that there is going to be tons of virtual hosts all with the same data so I don't want to have to copy the content of each file to all of the directories. I was thinking of using SSI to include the content into each page but that wouldn't help me much because you can't include stuff from outside the current host, domain etc. What I would like to do is have a main "includes" directory and have all of the different virtual hosts look to that directory for the contents of each file. This would save tons of time and editing the contents of 1 file is tons easier than editing a couple thousand. Does this make sense? If not, I can explain a bit more... If anyone has any ideas on how I could do this, that would be really great!!

Thanks a million!


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: including file from outside virtual host In reply to
If you are using unix (or linux) you can do a link between the main "include" directory and the virtual hosts directories, so that way you can use the include call throught SSI.
Another way is to do a cgi script that opens the file throught the real path not throught the url path. Something like this:

#!/usr/local/bin/perl
$include = /path_to_file/include.txt";
print "Content-type: text/html\n\n";
open(FILE, "$include");
@line = <FILE>;
print @line;
close(FILE);
exit;

This way is should work also. I hope this help.

Rogerio Morais
http://www.rogerle.com



[This message has been edited by Roger (edited April 06, 1999).]

[This message has been edited by Roger (edited April 06, 1999).]
Quote Reply
Re: including file from outside virtual host In reply to
Can you please explain your first idea in a bit more detail? The main site will be hosted on "Vservers.com" (unix) and the virtual hosts will be linked off of that. I am familiar with basic unix commands but I am just getting started with the server stuff for a client.

The 2nd idea is another way of doing it but wouldn't I have to have a cgi file for each file I want to include? I think the SSI way would be the best way to go about doing it.

Thanks for your help!


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: including file from outside virtual host In reply to
Hi jdulberg

It should be something like this:

Telnet to your server and on the directory of the virtual host type:

ln -s /path_to_directory/include include

This gonna create a symbolic link between the virtual host include directory and the main include directory

Quote Reply
Re: including file from outside virtual host In reply to
Roger,

The simplest way to do it is to have an alias in your apache configuration files to cover all the virtual hosts. So in srm.conf you would insert:

Code:
Alias /inc /path/to/includes/dir

So that no matter what vhost you're on, a request for /inc/file.inc will always come from the same directory. Just make sure you put it in the right place. If in doubt, don't play with your config files, get onto support@vservers.com and ask, they're usually pretty ok. Tell 'em the cranky Irish man sent ya. Smile Remember though that you can't use the directory /inc on any of your virtual hosts, they'll just be ignored.

Also remember that although the webspace suppliers say you can have unlimited domains on your server, you really can't. One, your server can only handle a certain amount of them and two, the more you have the slower it gets. Just thought you should know!

The Vservers page on srm.conf is here:

http://www.vservers.com/...;sec=3&subsec1=2

You'd do well to read the guide cover to cover, it's very educational!

Hope that helps you out,
adam

[This message has been edited by dahamsta (edited April 07, 1999).]
Quote Reply
Re: including file from outside virtual host In reply to
Thanks Roger and dahamsta for you help! This is going to save me a ton of time/hastle!!


------------------
Jason
Extreme mtb
http://extreme.nas.net