Mobile app version of vmapp.org
Login or Join
Cody1181609

: Trying to include a file from parent domain in subdomain? I am trying to include a php file from a parent domain in a subdomain. In subdomain.parentdomain.com/test.php i have include ('/var/www/vhosts/parentdomain.com/website/

@Cody1181609

Posted in: #Php #Subdomain

I am trying to include a php file from a parent domain in a subdomain.

In subdomain.parentdomain.com/test.php i have

include ('/var/www/vhosts/parentdomain.com/website/wp-blog-header.php');


My subdomain structure looks like

$_SERVER['DOCUMENT_ROOT'] gives /var/www/vhosts/parentdomain.com/subdomain.parentdomain.com


I have server access with plesk 11, but i don't know which php setting i have to change to enable including files from parent domain?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Cody1181609

2 Comments

Sorted by latest first Latest Oldest Best

 

@Courtney195

$url = file_get_contents('http://example.com/page.html');

You can get the contents of an external domain with this method. If this is somehow slower than calling the file directly from your server directory and that's the problem please do let me know.

If the issue is that you cannot use file_get_contents or similar commands with your PHP settings, you have to log into your PHP root control panel and modify your PHP. You need to set settings such as urlopen (or commands similar to that name) to ON. I've had to modify these settings in the past with new servers that I've setup.

10% popularity Vote Up Vote Down


 

@Twilah146

You can change PHP settings and the document root.

This should will help you to include files:

<?php

include_once $_SERVER['DOCUMENT_ROOT'] . '/../inc/header.php';


This part is the trick: /../

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme