简体   繁体   English

我可以编辑主机文件以查看新网站并仍然访问旧网站吗?

[英]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.

相关问题 我更改了主机文件,但看不到效果 - I changed hosts file but can't see effects 切换主机,.htaccess 301出现问题,从旧网站重定向到新网站 - Switched hosts, having issues with .htaccess 301 redirects from old website to new website 将网站从旧域名迁移到新域名 - Moving website from the old domain to the new one 如何向移动版 WordPress 网站添加 2 个单独的菜单? [一周岁,仍然需要帮助] - How can I add 2 separate menus to the mobile version of a WordPress website? [week old, still need help] 在旧版本仍然有效的情况下,如何从头开始建立新的Wordpress网站? - How to start a new Wordpress website from scratch while the old version is still live? 如何向我的网站添加自定义菜单,我需要编辑什么文件? - How can I add a custom menu to my website and what file would I need to edit? 我已经更改了 AWS EC2 实例的区域。 但是我看不到来自新 IP 地址和公共 DNS 的网站 - I've changed region for AWS EC2 instance. But I can't see a website from new IP address and Public DNS 上传新网站后,保留页面仍显示 - Holding page still showing after I have uploaded the new website 我正在切换主机但保持相同的域名。 当旧主机不再支持时,如何将旧 url 重定向到新 url? - I am switching hosts but keeping the same domain name. How do I redirect the old urls to the new urls when the old host will no longer be supporting? 如何让一个AWS子域网站指向另一个托管wordpress的EC2实例? - How can I have a AWS subdomain website point to another EC2 instance which hosts wordpress?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM