嵩明农家乐那家好:多个域名访问同一个网站时,用ServerAlias实现
来源:百度文库 编辑:偶看新闻 时间:2024/04/30 20:27:51
如果,想实现多个域名访问同一个网站时,可以使用ServerAlias来实现:
[b]前提条件:[/b]
已在域名服务提供商处或自己管理的DNS服务器上,将多个域名或A记录(如:test.com 、[url]www.test.com[/url] 、pub.test.com )指向同一个公网IP(如:166.166.166.166)
[b]此例中,Apache中涉及到的相关选项说明:[/b]
NameVirtualHost * (设定虚拟主机的ip)
(开头设定虚拟主机的ip)
ServerAdmin [email]admin@domain.com[/email] (设定虚拟主机的管理者信箱,不用和预设的网站管理者相同)
DocumentRoot /yourdir (指定虚拟主机的网站主目录)
ServerName domain.com (设定虚拟主机的名称,指定设定虚拟主机的UR)
ServerAlias [url]www.domain.com[/url] (设定虚拟主机的?名,例: WWW )
ErrorLog logs/?? ?? (虚拟主机发生错误时要记录在哪个目录,可不设.)
TransferLog logs/?? (虚拟主机存取记载要存放的个目录,可不设.)
(结束,要设第二组虚拟主机在从开头开始设)
[b]在Apache中的配置:[/b]
NameVirtualHost 166.166.166.166
ServerAdmin [email]admin@test.com[/email]
DocumentRoot /your/web/file/dir
ServerName test.com
ServerAlias [url]www.test.com[/url]
ServerAlias pub.test.com
ErrorLog logs/test.com_error_log
TransferLog logs/test.com_transfer_log
[b]如果没有条件设置域名,在windows环境下可以做如下测试:[/b]
修改hosts主机文件,用记事本打开:
C:\WINNT\system32\drivers\etc\hosts
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
[b]加入:[/b]
166.166.166.166 test.com
166.166.166.166 [url]www.test.com[/url]
166.166.166.166 pub.test.com
在CMD下测试PING这三个域名,如果通,就可以测试apache了。
[b]前提条件:[/b]
已在域名服务提供商处或自己管理的DNS服务器上,将多个域名或A记录(如:test.com 、[url]www.test.com[/url] 、pub.test.com )指向同一个公网IP(如:166.166.166.166)
[b]此例中,Apache中涉及到的相关选项说明:[/b]
NameVirtualHost * (设定虚拟主机的ip)
ServerAdmin [email]admin@domain.com[/email] (设定虚拟主机的管理者信箱,不用和预设的网站管理者相同)
DocumentRoot /yourdir (指定虚拟主机的网站主目录)
ServerName domain.com (设定虚拟主机的名称,指定设定虚拟主机的UR)
ServerAlias [url]www.domain.com[/url] (设定虚拟主机的?名,例: WWW )
ErrorLog logs/?? ?? (虚拟主机发生错误时要记录在哪个目录,可不设.)
TransferLog logs/?? (虚拟主机存取记载要存放的个目录,可不设.)
[b]在Apache中的配置:[/b]
NameVirtualHost 166.166.166.166
ServerAdmin [email]admin@test.com[/email]
DocumentRoot /your/web/file/dir
ServerName test.com
ServerAlias [url]www.test.com[/url]
ServerAlias pub.test.com
ErrorLog logs/test.com_error_log
TransferLog logs/test.com_transfer_log
[b]如果没有条件设置域名,在windows环境下可以做如下测试:[/b]
修改hosts主机文件,用记事本打开:
C:\WINNT\system32\drivers\etc\hosts
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
[b]加入:[/b]
166.166.166.166 test.com
166.166.166.166 [url]www.test.com[/url]
166.166.166.166 pub.test.com
在CMD下测试PING这三个域名,如果通,就可以测试apache了。
在alexa中如何将拥有多个域名的网站统统计到同一个域名中??
怎样把多个域名指上同一个地址
配置web服务基于一个IP对应多个域名并且要求输入IP时各个网站也能被访问该怎么做呢?
访问域名时出错
一个网站一直要我用域名访问怎么办?
在同一个局域网内,网站访问问题?
多个域名绑定一个ip,但不同的域名却访问了不同的站点
问:用域名访问网站很慢,直接用IP访问确很快,为什么?
如何使n个域名指向一个ip但是却访问的不同的网站?
多个域名怎么样指向网站
DNS里怎样把多个域名指上同一个地址
怎么样用域名访问HTTP
为什么同一个网站,用ie访问不了,用其他浏览器就可以打开?
多个网站使用同一个用户数据库解决办法
同一个网站可以有多个域名的吗?为什么?
同一个空间里使用2个以上域名如何在?
由外部用域名可以访问,单位的网站,可是在单位局域网内用域名却不能访问这是为什么?
我这里有个关于网站的问题:我有两个域名,我想通过设置达到不同域名访问不同首页的目的,不知道能否做到
帮忙取个网站域名。
某个网站有多个镜像服务器,每个镜像服务器的连接域名是用同一个还是各个都不同?
如何在一个空间里做2以上不同的网站(2个域名指向同一个空间不同的内容)
怎么把多个域名指向同一网站啊?
用这个域名做个网站可以吗?
WEB不可以用域名访问