使用 SSI(服务器端包含)
我正在尝试学习如何执行服务器端包含,因为我的项目需要它们。现在,我可以在本地使用 SSI 吗?我的网站是 100% HTML、Javascript 和 CSS,因此没有服务器运行我的内容。我只是在记事本中编辑文件。在将其上传到我计划将其发送到的服务器之前,我可以做些什么来允许我在 SSI 上工作。
I'm trying to learn how to do Server Side Includes because I need them for a project of mine. Now, can I use SSI locally? My site is 100% HTML, Javascript, and CSS, so there is no server running my stuff. I'm just editing the files in notepad. What can I do to allow me to work on SSI before I upload it to the server that I plan on sending it to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您没有运行服务器,则无法使用服务器端包含。线索就在名字里。因此,如果您在没有服务器的情况下在本地测试页面,那么您的 SSI 将无法工作。
能够执行此操作的唯一方法是在本地 PC 上安装 Web 服务器。
幸运的是,这相当容易。两个主要的 Web 服务器是 Apache 和 IIS。阿帕奇是免费的;您可以免费下载并安装它。 IIS 是一个商业产品(由 Microsoft 提供),但您可以免费安装一个精简版本。选择最适合您的一项(即与您的实际 Web 服务器匹配的一项),您应该能够让您的 SSI 代码正常工作。您可能需要做一些配置来设置它,但作为一名 Web 开发人员,知道如何做是一件好事。
If you're not running a server, then you can't use server-side includes. The clue is in the name. So if you're testing the page locally without a server, then your SSIs won't work.
The only way you're going to be able to do this is to install a web server on your local PC.
Fortunately this is fairly easy. The two major web servers are Apache and IIS. Apache is free; you can download it and install it for free. IIS is a commercial product (by Microsoft), but there is a cut-down version you can install for free. Pick whichever one is best for you (ie the one which matches your actual web server), and you should be able to get your SSI code working. You'll probably need to do some config to set it up, but as a web developer that's a good thing to know how to do.
您需要在本地运行服务器才能使 ssi 工作。您可以只安装 apache,或者使用 XAMPP(精简版)来获取 PHP 和 MySQL。
You need to run a server locally to make ssi work. You can install just apache, or use XAMPP (lite) to also get PHP and MySQL.
服务器端包含 (SSI) 是 Web 服务器的一项可选功能,可帮助开发人员使用一行代码将基本文件中的 HTML 文件内容包含到多个其他 HTML 文件中。如果我们要创建一个简单、优雅、快速的纯 HTML 站点,无需主动服务器计算,仅调用服务器的内容交付功能,我们就需要这个。
要在 IIS 7 及更高版本上运行 SSI,需要执行 3 个主要步骤:
这里有更详细的解释。
Server Side Includes (SSI) are an optional feature of the web servers helping the developers to include HTML file content from a base file into multiple other HTML files with a single line of code. We need this if we are creating a simple, elegant and fast pure HTML site, without active server computing, just invoking content delivery capabilities of the server.
There are 3 major steps required to get SSI running on IIS 7 and later:
HERE is a more detailed explanation.