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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to include or require a file over a sub-domain? 1

Status
Not open for further replies.

james0264

Programmer
Mar 1, 2005
52
GB
I have checked and searched the forum, but people who have either asked this question has not had a response or were irrelevant.

I want to know, whether it is possible to include() or require() a file over a sub-domain? In other words, if I have some files I want to include under I can link the files relative from another file in the domain. But can I do the same with someother.somedomain.com sub-domain? I haven't the vaguest idea of achieving this, apart from an absolute link; but that would include the file at the beginning without all the variables being retrieved or set first. Many thanks, James.
 
Assuming that safe mode is off, you can include files from anywhere on a server's filesystem.

If url_fopen in php.ini is set to on, you can include files from other web servers -- however, the foreign server must send back to your script PHP source code for this to work. If the foreign server simply runs the script to be included and returns nothing, your script will not work.


I'm perplexed by the part of your post that reads, "I haven't the vaguest idea of achieving this, apart from an absolute link;".

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Ah sleipnir214, thanks for your rapid reply. Since they are sub-domains, both documents are on the same server. They are just in different part of the server and I get a access denied when I try to access the file from a different sub-domain folder. About your question, I mean that if I try using the followin code, the document will be loaded first than where I put it in the document, and therefore skipping all the variables.
Code:
include('[URL unfurl="true"]http://www.somedomain.com');[/URL]
Many thanks, James.
 
If the files are all on the same server, I strongly recommend that you not use a URL-based include. Doing so eats up resources and will likely slow your computer.

include() is not constrained to the document root of your web site. So long as the user as which your web server runs has permission to read the file, you can include any file on the filesystem using an absolute path. Or you can tweak your include_path setting.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Well yes, like I said:
If I use a relative path, I get a "access denied" error since I can not include a file from one sub-domain to another for some odd reason.
If I use a absolute path, the document will be excuted first before anything else.
If there is a way to bypass the "access denied" error, I would be very grateful to know. Sorry if this is confusing, just I don't know any better way of explainaition.
 
Explicitly explain your directory structure.
Explain what you mean when you say, "use a relative path" and "use an abosolute path".

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Sorry about the delay. Anyhow, I will try and explain as well as I can:
My directory structure contains two fol
ders: httpdocs, subcomains and numerous other configuration folders that a reirrelevant. httpdocs folder stores the files that are viewed when tpying in the main domain address. subdomains contains folders which are the prefixes of the sub-domains names, such as a folder for someotherdomain.somedomain.com, would be someotherdomain. Each of these folder contains a httpdocs, which is the folder that stores the sub-domains files.
Relative path is "../../some_folder/some_other_folder/some_file.php", whereas absolute is " In other words, absolute URL is the address you would see in the Address bar. I hope this helps. many thanks for the support, James. I may not reply until tommroow, around 11 here, very tired.
 
Oh, and I forgot to mention, the server does nto allow me to use relative paths beyone (using ../) the httpdocs folder.
 
No.

An absolute path does not begin with " A URL path begins with " An absolute path will begin with a "/" (or on Win32 a drive letter and a colon) and describes the path to a file or directory, beginning at the root of your filesystem. For example, the absolute path to your document root might be "/var/
I recommend using absolute paths. Not URL or relative paths.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Oh right! I'm so sorry ;'(! I have learnt the information from another site, and they information it provided must have been incorrect. Many thanks for clearing this up. I'll try using the "correct" method of absolute path. Many thanks again, James.
 
I have just browsed the forum and found thread434-1156298, which explains that / combined with the path finder getcwd(); will find the path I can use to relate to the file. I have used this method and have found it sucessful. Many thanks for the help anyway guys. Many thanks, James.
 
Sorry for misleading you, the code did not work afterall. Could some explain how to enable the setting, as from the error below? Many thanks, James.

Warning: main(): URL file-access is disabled in the server configuration in /usr/local/psa/home/vhosts/eggwize.co.uk/httpdocs/index_renamepending.php on line 3
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top