2016-11-15 156 views
0

我有一个“domain.com”文件夹'user1'&'sub'。 现在我有一个子域“m.domain.com”,因为此子域具有根文件夹“domain.com/sub”。 子文件夹的根文件夹中有一个文件,即'm.domain.com/index.php' 我想通过使用'm.domain.com/index.php'将'user1'的名称更改为'user2' 。访问从根文件夹(php)升级一级的文件夹

我如何使用访问“domain.com/”的“m.domain.com/index.php”访问根目录的父文件夹,即 。

+0

代码在哪里?什么服务器?配置在哪里? –

回答

0

根据您的描述,网址m.domain.com/index.php指向文件domain.com/sub/index.php。所以,如果你想从index.php中的子域访问的主要站点文件,你可以使用相对路径开始../

例如:文件domain.com/sub/index.php(这相当于URL m.domain.com/index.php),我想包括文件library.php从文件夹user1的主域名。我使用:

include './../user1/library.php'; # the dot at the beginning denotes the current directory

+0

作为子域名“m.domain.com”的根目录是“domain.com/sub”。 所以我目前在'm.domain.com/index.php“,我想从”m.domain.com“的根目录访问一个级别,即' user1' 意思是:我想从'm.domain.com/index.php'取得'user1'的控制权 –

+0

_access_是什么意思?你想达到什么目的? –

+0

我想更改名称文件夹'user1'通过使用'm.domain.com/index.php' 因为你可以假设'm.domain.com/index.php'是持有的代码来改变文件夹的名称 当前我我在“m.domain.com/index.php”,我想从“m.domain.com”的根目录上升一级,并更改“user1”的名称。 –

0

如果服务器配置允许访问,你可以使用相对路径。

rename(__DIR__ . '/../user1', __DIR__ . '/../user2');