【问题标题】:change localhost directory to domain name through /etc/hosts通过 /etc/hosts 将 localhost 目录更改为域名
【发布时间】:2017-03-30 09:42:26
【问题描述】:

我想知道是否有人可以建议我如何将域指向本地主机中的目录而不是本地主机的根目录?

例如在我的主机文件中:

127.0.0.1 www.domain.com

  • 这行得通

127.0.0.1/directory/www.domain.com

  • 这不起作用?但是,我访问该域时需要查看的目录吗?

或者有没有更好的方法在您的本地主机中设置多个站点,因为我在自己的目录中设置每个站点?

任何帮助将不胜感激

谢谢

【问题讨论】:

    标签: dns localhost hosts


    【解决方案1】:

    您需要使用虚拟主机:

    <VirtualHost *:80>
    
      # Admin email, Server Name (domain name) and any aliases
      ServerAdmin webmaster@domain1.com
      ServerName  domain1.com
      ServerAlias www.domain1.com
    
    
      # Index file and Document Root (where the public files are located)
      DirectoryIndex index.html
      DocumentRoot /home/demo/public_html/domain1.com/public
    
    
      # Custom log file locations
      LogLevel warn
      ErrorLog /var/log/apache2/error-mydomainname.com.log
      CustomLog /var/log/apache2/access-mydomainname.com.log combined
    
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 2017-07-16
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 2018-07-16
      • 2013-11-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多