[英]Can I edit the hosts file to see the new website and still access the old one?
I'm developing a new website that will have the same domain name as the current old one, but a different host. 我正在开发一个新网站,该网站的域名与当前的旧域名相同,但主机不同。 The new one doesn't have DNS nameservers pointed to it yet, but I edited the hosts file on my computer to be able to access it. 新的服务器还没有指向它的DNS名称服务器,但是我在计算机上编辑了hosts文件以便能够访问它。 Is there a way I can now still access the old current one on the same computer, since it would help me with development, without changing the hosts file everytime? 现在有什么方法可以仍然在同一台计算机上访问旧的旧计算机,因为它可以帮助我进行开发,而不必每次都更改主机文件?
Thanks :) 谢谢 :)
You can check the old site by using the temporary URL 您可以使用临时URL检查旧站点
http://server_ip/~cpanelusername/
but many of host block ip preview. 但是许多主机阻止ip预览。 You also can use archive.org. 您也可以使用archive.org。 You can save the old site before starting new. 您可以在开始新站点之前保存旧站点。
For this type scenario, I use a subdomain to built a new site. 对于这种类型的方案,我使用子域来构建新站点。
www.mysite.com >> www.dev.mysite.com
If possible, it can be helpful to set up an alias and then create an A record for that alias that points to the new site. 如果可能,设置别名,然后为该别名创建指向新站点的A记录可能会有所帮助。 This allows you to reach the new site via a different name but it will still look at all the files and database(s) as it would normally. 这使您可以使用其他名称访问新站点,但仍会像往常一样查看所有文件和数据库。
This is helpful for when you want to test the new site before it goes live without having to comment and uncomment the hosts file continuously. 当您要在新站点上线之前对其进行测试而不必连续注释和取消注释主机文件时,这将很有用。
One thing to watch out for is that any URLs that are the full URL such as example.com/whatever
instead of /whatever
won't work. 需要注意的一件事是,完整URL的任何URL(例如example.com/whatever
而不是/whatever
将不起作用。 However, as it is generally bad practise to do the full URL in case the domain ever changes; 但是,由于通常不建议使用完整的URL,以防域发生更改。 this can be a good way of finding and corrected any. 这可能是查找和更正任何问题的好方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.