0
我在Ubuntu 14.04上用LAMP制作了简单的http服务器,并将我的html,php和js文件放到了Apache根目录/var/www/。这些文件中的所有路径都是绝对路径,看起来像/script1.php或/subdir/script.php。 Web服务器的目录树是这个样子:从服务器根目录重定向到apache根目录
/
|---var
|---www
|---script1.php
|---subdir
|---usr
|---home
|---etc
文件/etc/apache2/sites-available/000-default.conf:
ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
Alias /data /var/www/
<Location /data>
DAV On
AuthType Digest
AuthName "webdav"
AuthUserFile /usr/local/apache2/.digest_passwd.dav
Require valid-user
Order Allow,Deny
Allow from all
DirectoryIndex disabled
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
的问题是在指出所有路径从根服务器目录开始。
例如,PHP命令执行opendir( '/')显示列表:
/
|---var
|---usr
|---home
|---etc
,但我需要列表一样,
/
|---subdir
|---script1.php
所以,我怎样才能让Apache认为'/'意味着不是根网站服务器目录,而是根目录apache?
我不认为这是可能,更好地利用变量存储的document_root绝对路径,然后用实际项目串接文件夹 // $ site_root ='/ vat/www /'; opendir($ site_root.'subdir');或者看看这里http://www.php.net/manual/en/language.constants.predefined.php –
或使用$ _SERVER ['DOCUMENT_ROOT']; http://php.net/manual/en/reserved.variables.server.php –
谢谢你的答案。我会试试 – Andrew