我尝试禁止基本 80 HTTP 服务器位于我的动态 DNS 的根目录,而是使用子目录。
因此,
blabla.dynamicdns.org
它不会被提供,而是
blabla.dynamicdns.org/service
会被提供。
此配置尝试无效。提示“目录”标签中不允许有文档根目录。
我知道 SE 多么喜欢它的示例,无论如何我都会在这里转储这个原始配置。
我真的什么都不知道,我真的需要有人来指导,而谷歌搜索就是解决这一问题的方法。
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
<Directory /var/www/html/ampache/>
DocumentRoot /var/www/html/ampache
DocumentRoot /var/www/html/ampache/public
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
更正确的配置,但仍然没有产生我想要的结果:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/ampache
DocumentRoot /var/www/html/ampache/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
很抱歉造成这种事实上的垃圾邮件,但是我使用 SE 的经历以及对那些我甚至不知道它们如何工作的主题的“工作示例”的渴望,迫使我这样做。
DocumentRoot
/
始终定义(URL 的根目录)的映射。要定义 URL 子目录的映射,请使用Alias
。请参阅映射 URL以了解一般概述。(粗略的说,
DocumentRoot /var/foo
就像Alias "/" /var/foo
。)如果您不想在 提供任何服务
/
,请将 DocumentRoot 映射到一个空目录(甚至可能是具有受限权限的目录)并使用 Alias 来定义您想要的各个子目录。每个虚拟主机拥有多个 DocumentRoot 是没有意义的,因为它们都会定义相同的映射
/
,并且 URL 一次只能转到一个位置 - 只会使用最后一个定义。同样,多次使用同一条路径的别名也是没有意义的。