简体   繁体   English

httpd.conf多个虚拟主机

[英]httpd.conf multiple virtual hosts

Coding for PHP on Mac OSX Lion, using the following within the httpd.conf file: 在Mac OSX Lion上为PHP编码,在httpd.conf文件中使用以下代码:

<VirtualHost *:80>
    DocumentRoot /Users/user/Sites/wordpress
    ServerName wordpress.local
    <Directory “/Users/user/Sites/wordpress">
        AllowOverride All
        Options All
    </Directory>
</VirtualHost>

and in the hosts file: 并在hosts文件中:

127.0.0.1 wordpress.local

This all works fine. 这一切都很好。 What I want to be able to do is allow that first section to accept some sort of wildcard so that I can add several pages to the hosts file, but not have to keep messing with the httpd.conf file. 我想要做的是允许第一部分接受某种通配符,这样我就可以将几页添加到hosts文件,而不必一直弄乱httpd.conf文件。 I used to be able to use %1 and %0 instead of the directory name to get this working, but there now seems to be a problem with that. 我曾经能够使用%1和%0而不是目录名称来使此工作正常进行,但是现在似乎存在问题。

All help much appreciated. 所有帮助,不胜感激。

Cheers, David. 干杯,大卫。

The following blogpost by Rob Allen should help, I think : Automatic Apache vhosts 以下是Rob Allen的博文,我认为应该有所帮助: 自动Apache虚拟主机

The first part of the article is about mod_vhost_alias , which will allow you to use wildcards for ServerAlias , a VirtualDocumentRoot directive it adds, and Directory . 本文的第一部分是有关mod_vhost_alias ,它将允许您对ServerAlias ,它添加的VirtualDocumentRoot指令以及Directory使用通配符。

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

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