简体   繁体   English

Apache virtualhost指令:仅ServerName,仅此而已

[英]Apache virtualhost directive: only ServerName, nothing else

If I create a vhost directive, it will always catch all requests on this IP address. 如果我创建一个vhost指令,它将始终捕获该IP地址上的所有请求。 Even if I set a ServerName, all other requests will be redirected to the DocumentRoot of this entry. 即使设置了ServerName,所有其他请求也将重定向到该条目的DocumentRoot。 How can I drop all requests except to this specific domain? 我如何才能除该特定域以外的所有请求删除 Eg: 例如:

VirtualHost 46.108.122.78:80
    ServerName mysite.com

(I know that I can specify a second directive without ServerName and redirect eg to an empty dir. However, I want to explicitly drop these requests.) (我知道我可以指定不带ServerName的第二条指令,并将其重定向到例如空目录。但是,我想显式删除这些请求。)

The first name-based virtualhost for a given ip:port is the default when no other servername/serveralias matches. 当没有其他服务器名/服务器别名匹配时,给定ip:port的第一个基于名称的虚拟主机是默认主机。

# not necessary in 2.4
NameVirtualHost 46.108.122.78:80

<VirtualHost 46.108.122.78:80>
ServerName xxx.example.com
# any unmatched hostname on goes here
RewriteEngine on
RewriteRule .* - [F]
</VirtualHost>
<VirtualHost 46.108.122.78:80>
ServerName foo.example.com
DocumentRoot ...
</VirtualHost>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM