Forum Moderators: coopster
Having a dilema...
Started to use simple .php includes until i discovered my offline software and apache couldnt cope with that...so changed it all to .txt includes instead. Worked fine with apache and software. Until i went to put the files into subdomains online! Then whatever path i tried failed to find the includes. I have since discovered that subdomains are treated as a seperate server and so .txt includes dont work, but .php includes do!
I have heard about SymLinks and that they do a workaround for .txt includes. Anyone got any ideas on how to code them and whether you need root access for them to work?
I have since installed v4 php as a module for apache and now my php includes work offline. However, if i am to use php includes from each subdomain, then i will have to name the full path (http...) which will be very slow in comparison to the relative path of a symlink. The Symlinks option looks good as it just redirects from within the root folder rather than starting again with [......]
cheers,
Tom
I don't think symlinks are what you're after, but we'll come back to that.
First, you normally wouldn't want to do includes via the webserver (i.e. using a link like h**p://some/address/to/file.php" or ./to/file.php). This will be an order of magnitude slower than using the file system as in
include('/home/path/to/file.php');
Second, HOW you do the include will not affect whether or not it is parsed as php. That will be determined by your server settings. It sounds like you now have your server settings figured out and are parsing any file ending in .php as PHP and files ending in .txt as text. It's probably best to leave it that way.
Finally, as for how symlinks work... Symlinks are a feature of *nix operating system that makes it look as though a file had a different name. You may not have sufficient privileges to make them work on your system.
Let's say you are currently in the /home/htdocs/
In that directory you create a symlink
ln -s /home/directory/with/subdomain/documents subdomain_name
You should now have a symlink such that when you request
include('/home/htdocs/subdomain_name/file.php');
you will actually be getting
/home/directory/with/subdomain/documents/file.php
But from a scripting point of view, this is no more efficient (actually infintesimally less efficient) than simply doing your include straight to the file you want in the first place as in
include('/home/directory/with/subdomain/documents/file.php');
If you do want symlinks to work via the browser, you will need to either add a
Options FollowSymLinks
directive in either a .htaccess or
<Directory /usr/local/httpd/htdocs>
Options FollowSymLinks
</Directory>
in your httpd.conf.
Tom
Thanks for the info.
Do you know how to reference back to a main domain from a subdomain that has been called by its
'a' h--p://abc.xyz.com format rather than its
'b' h--p://www.xyz.com/abc/
I cant seem to find the folder/file when the page has been called by the 'a' format, but is fine when using the 'b' format.
I'm using with no joy '/home/username/public_html/includes/file.php'
All the nav links will be by the 'a' format so that the spiders see each subdomain as a new domain and not just a folder off the main domain!
The 'includes' will then be referenced by file system and not h--p format.
Also do you know how to store the php page snippets in the user's cache, as each element rarely changes from page to page. I know how to store images in the cache, but have not found out how to store parts of a page.
Cheers,
Tom