'PHP Include from second domain/subdomain on same server

I try to include a php file from the same server but a different domain within a php site (domain.com).

include 'domain2.com/file.php';

the file should look like this for example:

echo 'test';

I now want the main site to have the file.php included to echo 'test' on the site. However, it doesn't. Does anybody have an idea how I could solve that?

My thoughts are the following, though I cannot solve it myself. Maybe they help you to come up with a solution:

  • It seems like it is included but the file.php does not return anything, because the php is being run on 'the other domain's server'. So the echo could be done in the other file, but is not included within the main site.

Note that if I include via path, it works:

include '../domain2/file.php';

Note also that allow_url_include and allow_url_fopen are allowed in the php.ini.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source