How to change localhost/site to site.dev

爱⌒轻易说出口 提交于 2020-01-13 07:19:49

问题


I use XAMPP for local development and I've heard of developers that change the url structure from localhost/site to site.dev, but I'm not sure how to go about it.

How can I change it and is there anything I should know before changing it?


回答1:


You'll need to add an entry in your host file to map site.dev to localhost

127.0.0.1 site.dev www.site.dev

and add a virtual host in apache to detect it

<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:


You can point site.dev to 127.0.0.1 in your hosts file and create a binding for the url in the apache config file so that requests from that url point at a specific site/folder in xampp. I've done this in the past for development projects and generally works pretty well.



来源:https://stackoverflow.com/questions/11090759/how-to-change-localhost-site-to-site-dev

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!