把域名解析到本地局域网,用域名访问局域网

cnlogo8 2018-12-18 3030

把域名解析到本地局域网,用域名访问局域网。

1.w10没有hosts文件:按下Windows 徽标键 +R键,点击“运行”,输入CMD ,复制粘贴下面代码,按下Enter键就出现了hosts文件

for /f %P in ('dir %windir%\WinSxS\hosts /b /s') do copy %P %windir%\System32\drivers\etc & echo %P & Notepad %P

2.hosts配置:
用编辑器打开hosts文件,位置: C:\Windows\System32\drivers\etc 目录下

在hosts文件里添加自己的域名配置,配置规则如下:

127.0.0.1   自定义域名

3.apache配置:

①打开 apache 下 conf 目录下的 httpd.conf 文件,在里面找到  #Include conf/extra/httpd-vhosts.conf,去掉前面的#


②打开 Apache\conf\extra\ 目录下进入开启的虚拟主机文件 httpd-vhosts.conf 进行域名配置


最新回复 (2)
全部楼主
  • cnlogo8 2018-12-18
    0 2

    把域名解析到


    本地ip

    192.168.1.4

  • tiktok 2019-1-22
    0 3
    #
    # Virtual Hosts
    #
    # If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #
    # Please see the documentation at 
    # <URL:http://httpd.apache.org/docs/2.2/vhosts/>
    # for further details before you try to setup virtual hosts.
    #
    # You may use the command line option '-S' to verify your virtual host
    # configuration.
    #
    # Use name-based virtual hosting.
    #
    NameVirtualHost *:80
    #
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for all requests that do not
    # match a ServerName or ServerAlias in any <VirtualHost> block.
    #
    <VirtualHost *:80>
        ServerAdmin webmaster@dummy-host.example.com
        DocumentRoot "c:/Apache2/docs/dummy-host.example.com"
        ServerName dummy-host.example.com
        ServerAlias www.dummy-host.example.com
        ErrorLog "logs/dummy-host.example.com-error.log"
        CustomLog "logs/dummy-host.example.com-access.log" common
    </VirtualHost>
    <VirtualHost *:80>
        ServerAdmin webmaster@dummy-host2.example.com
        DocumentRoot "c:/Apache2/docs/dummy-host2.example.com"
        ServerName dummy-host2.example.com
        ErrorLog "logs/dummy-host2.example.com-error.log"
        CustomLog "logs/dummy-host2.example.com-access.log" common
    </VirtualHost>


返回