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

Xampp 如何将localhost/site更改为site.dev,xampp,Xampp,我使用XAMPP进行本地开发,我听说过一些开发人员将url结构从localhost/site更改为site.dev,但我不知道如何进行 如何更改它,以及在更改它之前有什么我应该知道的吗?您可以在主机文件中将site.dev指向127.0.0.1,并在apache配置文件中为url创建绑定,以便来自该url的请求指向xampp中的特定站点/文件夹。 我在过去的开发项目中做过这项工作,通常效果很好 您需要在主机文件中添加一个条目,以将site.dev映射到localhost 127.0.0.1 si

我使用XAMPP进行本地开发,我听说过一些开发人员将url结构从localhost/site更改为site.dev,但我不知道如何进行


如何更改它,以及在更改它之前有什么我应该知道的吗?

您可以在主机文件中将site.dev指向127.0.0.1,并在apache配置文件中为url创建绑定,以便来自该url的请求指向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>

DocumentRoot/path/to/document/root/site/
ServerName site.dev
ServerAlias www.site.dev
#这里还有其他指示
DocumentRoot/path/to/document/root/
服务器名本地主机
#这里还有其他指示