复制整个网站的最佳方法是什么?
我为一位客户构建了一个复杂的网站,他希望对其进行复制和重新设计,以便可以用于其他方式。
这样做的最佳方法是什么?我担心复制每个文件,因为这意味着任何错误都必须修复两次,任何改进都必须实施两次。
I've built a complex site for a client, who wants this duplicated, and re-skinned, so it can be used for other means.
What is the best way of doing this? I'm concerned about copying every file as this means any bugs must be fixed twice, and any improvements must be implmented twice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我想重构你的代码。
将常用函数移至可以从两个项目中引用的库中。当您提到新站点用于不同目的时,您可能会看到分歧,并且您不想以后妨碍自己,因此提取公共部分,然后修改其余部分的副本(或者如果适当的话新文件)以完成你的叉子。
如果您还没有应用良好的实践,那么现在是时候这样做了,这将使您在两个站点上的工作更容易向前推进。
I'd look to refactor your code.
Move common functions into a library you can reference from both projects. As you mention that the new site is for a different purpose then you are likely to see divergence and you don't want to hamper yourself later, so extract the common parts and then modify copies (or if appropriate new files) of the remainder to complete your fork.
If you haven't applied good practice already then now is the time to do it and it'll make your work on both sites easier moving forward.
如果所有功能都相同,只有布局不同,您可以创建一个新的 css 文件。 2 个网站可以具有完全相同的代码库,但具有不同的样式表并且看起来完全不同。
If all the functionality is the same and only the layout is different you could just create a new css file. 2 websites could have exactly the same code base but have different stylesheets and look completely different.
我认为使用版本控制系统(例如 subversion 或最好是 git)是复制网站的好方法。您将能够跟踪所做的更改,并在出现问题时恢复到旧版本。
I think that using a version control system like subversion or preferably git, is a good way to duplicate your website. You will be able to track the changes that you make and revert to older versions if things do not work out.
您应该实现某种实例化,因此外观、内容和数据将根据访问的应用程序实例来显示。
换句话说,每个应用程序都使用不同的应用程序标识符访问代码,这意味着将根据它来提供内容。
两个应用程序标识符将指向不同的设置,因此样式表和内容将绝对隔离,并且两个域将位于同一个 IIS 应用程序中。
You should implement some kind of instantiation, so look and feel, content and data will be shown depending of what instance of the application is accessed.
In other words, each application access to the code with a different application identifier, meaning content will be served depending on it.
Both application identifier will be pointing to different settings, so stylesheet and content will be absolutely isolated, and both domain will be living in the same IIS application.
如果您想复制整个网站,最好复制整个网站并根据需要进行修改。显然,要非常小心,不要复制大部分文本,否则您可能会受到搜索引擎的惩罚。
有多种方法可以将新站点放在同一共享主机上(例如在原始站点的子目录中)并从字面上“共享”一些文件。如果需要进行唯一的更改,您可以引用特定文件的“本地”版本。
然而,这对我来说听起来像是一个令人头痛的秘诀。我更愿意复制整个网站。替换不同网站上的一两个功能比尝试找出哪个网站受到源的特定更改的影响要容易得多。
If you want to duplicate a whole site it's probably best to copy the whole thing and amend as necessary. Obviously taking great care not to copy large portions of text or else you may be penalised by the search engines.
There are ways you could put the new site onto the same shared host (say within a subdirectory of the original site) and literally 'share' some files. If a unique change is required, you could instead reference a 'local' version of a particular file.
However that sounds like a recipe for a headache to me. I'd prefer to duplicate the whole site. It would be much easier to replace one or two functions on separate websites than it would to try and work out which website(s) are affected by a particular change to your source.