-1

I need to include a url with php from my base domain www.site.it in some pages from a third level domain (www.cms.site.it). I know that include external files is possible by enable the php.ini commandsa allow_url_include and allow_url_fopen, but this is not possible with my provider. Maybe it's some other possibility since it is always the same domain?

Samuel
  • 43
  • 7

1 Answers1

0

If the files lay on the same file system and you have access to them via your php script you should be able to include them.

Domains are just pointing to an IP and the server is showing the required content, so basicly you can have: a.example.com pointing on one server and b.example.com pointing on another server. If should be clear that you cannot include a file from the one server to the other.

When multiple sub-domains are involved in most of the cases they are on the same server and on the same file system but the scripts for each sub-domain are located in a folder and have access only in the current folder so in most cases you will not be able to do it.

If you have access to the files from the file-system the domains and the sub-domains have no role in this.

Finally - when it comes to shared hostings most domains and sub-domains are located in separate folders and the scripts in them have access to the current folder only. This is done for security reasons so in your case if you have a sub-domain that is yours you will not be able to access the files used in the main domain in the shared hosting.

  • I have explained badly. I have to include a url (on the www.site.it) that contains php functions using the include() function, in a page on cms.site.it. – Samuel Apr 16 '14 at 14:15
  • Are both domains on the same file system and do they have access to each-other's files? – Дамян Станчев Apr 16 '14 at 14:16
  • Yes I think so, they should be on the same file system even if it is shared hosting. – Samuel Apr 16 '14 at 14:26
  • Then you should be able to include them via *include(dirname( _ _FILE_ _ ).[RELATIVE PATH GOES HERE])* where *dirname( _ _FILE_ _ )* will return you the real folder path to the current file and then you will have to go relativly to the file you require. Example: *include(dirname( _ _FILE_ _ ).'../other_directory/file.php')*. You might want to replace the slashes with DIRECTORY_SEPARATOR just to make sure the path is correct. P.S _ _FILE_ _ should be without spaces, but the markup does not allow me to do it. – Дамян Станчев Apr 16 '14 at 15:11