【发布时间】:2012-06-20 21:21:19
【问题描述】:
我使用 XAMPP 进行本地开发,我听说有开发人员将 url 结构从 localhost/site 更改为 site.dev,但我不知道该怎么做。
如何更改它,在更改之前我应该知道什么?
【问题讨论】:
标签: xampp
我使用 XAMPP 进行本地开发,我听说有开发人员将 url 结构从 localhost/site 更改为 site.dev,但我不知道该怎么做。
如何更改它,在更改之前我应该知道什么?
【问题讨论】:
标签: xampp
您需要在主机文件中添加一个条目以将 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>
【讨论】:
您可以在 hosts 文件中将 site.dev 指向 127.0.0.1,并为 apache 配置文件中的 url 创建一个绑定,以便来自该 url 的请求指向 xampp 中的特定站点/文件夹。 我过去曾为开发项目这样做过,并且通常效果很好。
【讨论】: