Quote:
Originally posted by Grump@Apr 26 2005, 02:55 PM
It can be on a different domain on the same server if you use the server path in a php call, not sure about from a different server.
include("/home/username/domainname/foldername/filename.txt"); ?>
EDIT- I think it can also be done across domains on the same server without php using a virtual folder.
|
It depends on how your server is set up :-0)
There are times when it's advisable to have php includes outside of the web root (usually /html/), so you can only include it like:
include("/home/path/to/file"); ?>
Most common these days is to slap it in a folder inside the web root, so you can use relative or absolute linking as you would any other file on the server.
Relative:
include("/path/to/file"); ?>
Absolute:
include("http:www.domain.com/path/to/file"); ?>
(NB: this will allow it to be linked to from *any* domain, on-server or off-server - it can cause probs because php can only handle a certain amount of full URL connections).
If you have multiple domains on a server but only want to have one folder serving all the includes, you can either call it all from one location (/home/path/to/file) or you can be sneaky and alias /symlink a folder so it can be relative across all domains. You can do this in htaccess but it's better to alias stuff in apache config.
EG in your html you'd include "/includefolder/file" which would to all intents and purposes be served from domain.com/includefolder/file but in reality is served from /some/other/location/includefolder/file