2016-11-15 159 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');