douman9420 2015-06-17 15:18
浏览 29

从www root外部显示php页面的PHP脚本

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line