设置一个默认的Apache虚拟主机 [英] setting a default apache virtual host

查看:120
本文介绍了设置一个默认的Apache虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有设置比它只是挑选它找到的第一个配置其他默认的Apache虚拟主机没有更好的办法?

Is there any better way of setting the default apache virtual host other than it just picking the first config it finds?

我跟很多领域,其中只有部分配置了httpd的,但默认的虚拟主机切断了服务器例如是aaa.com因为在那里我真的希望它默认而不是mmm.com?

I have a server with many domains, of which only some are configured with httpd but the default virtual host severed up is for example is aaa.com where as really I would like it to default to mmm.com instead?

喜欢的东西停车域,而无需通过设置一个配置,每一个的麻烦会 - 那么我可以成为一个网页这个领域还没有被创建的内容?

Something like parking domains without going through the hassle of setting up a config for each one - then I can serve a "content this domain has not been created yet" page?

干杯

推荐答案

您可以创建一个默认的虚拟主机并将其命名为类似 000默认,以便它加载第一并使用,除非匹配请求域中的另一个虚拟主机中找到。以下是最基本的 000默认

You can create a default virtual host and name it something like 000-default so that it loads first and is used unless another vhost matching the requested domain is found. Here's the bare-bones 000-default:

<VirtualHost *:80>
    DocumentRoot /var/www
    <Directory /var/www >
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

然后就可以设置在 /无功/网络的PHP文件创建一个域名停放页面(这是一个非常简单的例子):

Then you can setup a PHP file under /var/www to create a domain parking page (this is a very simplified example):

<?php

printf('The domain <b>%s</b> is being parked', 
    htmlentities($_SERVER['HTTP_HOST']));

?>

这篇关于设置一个默认的Apache虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆