如何将localhost / site更改为site.dev

时间:2012-06-18 20:46:28

标签: xampp

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

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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分: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>
相关问题