0

我终于找到了如何设置子域以指向我服务器上的各种目录。例如:

http://helloworld.dev.example.com => /local/www/static/helloworld

使用这个:

<VirtualHost *:80>
    VirtualDocumentRoot /local/www/static/%1
    ServerAlias *.dev.localhost
</VirtualHost>

它有效,而且很棒,但我有一些问题。一个是我想在我的主机文件中的本地机器上创建一个指向该服务器 IP 的别名。所以当我在家时,我可以去:

hello.dev.myserver

但是,虽然它适用于我的主域,但当我转到该地址时它不起作用。我知道它配置正确,因为如果我去http://myserver/我会得到这个。

The requested URL / was not found on this server.

但是http://hello.dev.myserver/不起作用。我将主机名设置为域(显然不同)example.co.uk。可能与此有关吗?

我怀疑第二个问题将在第一个问题得到解决时得到解决,我如何托管多个域?我想托管我的朋友网站。

4

2 回答 2

1

我不知道您使用的是什么系统,但在 Windows 上,我在端口 80 上运行 IIS,在端口 8080 上运行 Apache,现在最后一部分有多个 wordpress 单站点和多站点(网络安装)。下面的代码有效

-

#truncated hosts file at c:/windows/system32/drivers/etc/hosts

127.0.0.1 localhost
#must match the 
127.0.0.1 sx.localhost twt.localhost upse.localhost veet.localhost brbox.localhost eunoia.localhost
127.0.0.1 wp.dev

-

以下所有内容都是 D:\xampp\apache\conf\extra\httpd-vhosts 的一部分

NameVirtualHost *:8080

<VirtualHost *:8080>
    DocumentRoot "D:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

/这是一个正常工作的 wordpress 普通 wordpress 博客。abce.localhost 必须与上面的hosts文件匹配,只是不断添加它们,但子域多站点(网络必须始终在最后)

<VirtualHost *:8080>
    DocumentRoot "D:/xampp/htdocs/ki/abce/wordpress"
    ServerName abce.localhost
    <Directory "D:/xampp/htdocs/ki/abce/wordpress">
    Options Indexes FollowSymLinks ExecCGI Includes
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

/下面是如果不是 8080 问题,网络子域博客将如何工作

<VirtualHost *:8080>
    DocumentRoot "D:/xampp/htdocs/alllive/wordpress"
    ServerAlias *.wp.dev
    ServerName wp.dev
    <Directory "D:/xampp/htdocs/alllive/wordpress">
    Options Indexes FollowSymLinks ExecCGI Includes
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

-

于 2012-08-12T02:44:35.617 回答
1

您的所有主机文件所做的就是将地址解析为 IP,然后使用它。hello.dev.myserver 未转发。至于托管您朋友的站点,您需要设置一个 VirtualHost,并将他的域设置为 ServerAlias,然后将 A 记录指向您的站点。

于 2012-08-10T10:23:00.387 回答