PHP script that shows php page from outside of www root

142 views Asked by At

I want to create a script in PHP that can show every site on the server even this that doesn't have the domain and are outside of www root and are writen in php.

I've achieved this with the third approach on my test environment on the xampp and it was doing perfect, but now I've tried to do it on live server and it tries to open domain.xxx/common-files/someSite/index.php - so it just doesn't work.

Beside the include and readfile methods does not satisfy me, because, of course they doesn't see all css / image files of the site which I'm trying to show.

$getSite = $_GET[ 's' ];

// First Approach - doesn't work at all
include_once "../common-files/$getSite/index.php";
exit;

// Second approach - works but I've got HTMl and all PHP code as plain text 
ob_start();
header( "Content-Type: text/html; charset=utf-8" );
@readfile( "../common-files/$getSite/index.php" );
ob_end_flush();
exit;

// Third Approach - on localhost works perfect - but on live server it doesn't.
header( "location: ../common-files/$getSite/index.php" );
exit;

I would appreciate any helpful advices how I can achieve it.

EDIT:

I see that there are no answers - so maye it is not possible to do it other way, so I will rephrase my question. If I will get the possibility to change some of server settings what I'm supposed to change in order to make header requests work outside of sites root folder? ( I have already accessible file system - I can create / move / copy / delete folders and files outside my directory but still my header requests points to my webroot and then searches for given folder which is of course not there ) My hierarchy is:

... /home/www/
    site01.com/
    site02.com/
    my_mainsite.com/
    site03.com/
    site04.com/
    site05.com/

And I want to be able to request header in e.g. site01.com/index.php from script inside of my_mainsite.com

0

There are 0 answers