多个域的Apache默认虚拟主机 [英] Apache default virtual host for multiple domains

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

问题描述

我有,例如,site1.com、site2.com,在他们自己的文件中配置了他们自己的虚拟主机,这些主机位于启用 apaches 和可用的文件夹中,在服务器上他们自己的物理文件夹中,并且具有不同的 .htaccess,它们是工作正常.现在,我希望所有其他未单独配置的域(例如 site3.com、site4.com ....)具有相同的虚拟主机、相同的物理文件夹,并执行相同的/folder1/folder2/index.html.php 文件.到目前为止,我已经制作了一些虚拟主机,但我得到的只是它正在工作",可能是因为所有内容都从默认虚拟主机重定向到了/var/www.但是,如果我在该文件中设置 DocumentRoot 指令,则 .htaccess 出于某种原因无法正常工作,并且我说已定义的站点工作正常.虚拟主机文件应该叫什么,内容应该是什么?

I have, for example site1.com, site2.com, configured with their own virtual hosts in their own files in the apaches enabled and available folders, in their own physical folders on the server and with different .htaccess and they are working fine. Now I want all the other domains that are not separately configured (for example site3.com, site4.com ....) to have one same virtual host, same physical folder, and to execute the same /folder1/folder2/index.php file. So far, I've made some virtual hosts but all I get is "It's working", probably because everything is redirected from the default virtual host to the /var/www. But if I set the DocumentRoot directive in that file, the .htaccess for some reason is not working, and I said that for the defined sites are working OK. What the virtual host file should be called, what should be it's content?

推荐答案

您可以定义一个 VirtualHost 容器,该容器具有尽可能多的 ServerAlias 条目.

You can define a VirtualHost container that has as many ServerAlias entries as you need.

这是一个非常简单的例子:

Here's a very simplified example:

<VirtualHost *>
    ServerName site3.com
    ServerAlias site4.com
    DocumentRoot /var/www/folder1/folder2
</VirtualHost>

如果您已经尝试过创建 vhost 文件,您是否重新启动了 apache?

If you've already tried creating vhost files, have you restarted apache?

在哪里放置 vhost 文件取决于您使用的发行版.如果您不熟悉发行版上的内容,请查看 http://wiki.apache.org/httpd/DistrosDefaultLayout.

Where to put the vhost files depends on what distro you're using. If you're not familiar with where stuff goes on your distro, check http://wiki.apache.org/httpd/DistrosDefaultLayout.

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

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