【问题标题】:How to change localhost/site to site.dev如何将 localhost/site 更改为 site.dev
【发布时间】:2012-06-20 21:21:19
【问题描述】:

我使用 XAMPP 进行本地开发,我听说有开发人员将 url 结构从 localhost/site 更改为 site.dev,但我不知道该怎么做。

如何更改它,在更改之前我应该​​知道什么?

【问题讨论】:

    标签: xampp


    【解决方案1】:

    您需要在主机文件中添加一个条目以将 site.dev 映射到 localhost

    127.0.0.1 site.dev www.site.dev
    

    并在apache中添加一个虚拟主机来检测它

    <VirtualHost *:80>
        DocumentRoot /path/to/document/root/site/
        ServerName site.dev
        ServerAlias  www.site.dev
    # Other directives here
    </VirtualHost>
    
    <VirtualHost *:80>
        DocumentRoot /path/to/document/root/
        ServerName localhost
    # Other directives here
    </VirtualHost>
    

    【讨论】:

      【解决方案2】:

      您可以在 hosts 文件中将 site.dev 指向 127.0.0.1,并为 apache 配置文件中的 url 创建一个绑定,以便来自该 url 的请求指向 xampp 中的特定站点/文件夹。 我过去曾为开发项目这样做过,并且通常效果很好。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-20
        • 2011-08-03
        • 2021-05-11
        • 1970-01-01
        • 2017-07-16
        • 2013-06-30
        • 1970-01-01
        • 2018-12-04
        相关资源
        最近更新 更多