2

首先,我如何知道我的 html 文件是否在 Xampp 的 localhost 上运行?是否有关于如何管理文件/目录并使所有这些都在 htdocs 下工作的教程?是否有关于如何设置包含的好教程?

我想在我的 html 中使用 Xampp 中的“包含”。我可以同时使用 html 包含和 php 包含吗?我必须放shtml吗?我可以使用 shtml、html、htm 和 php 包含吗?它们是否必须在一个包含目录中,该目录是 htdocs 下的子目录?我可以在其他子目录中引用包含吗?我的网站将有 100 多个页面,我正在尝试使用不同的版本进行“实验”,直到我满意为止。所以,我有各种下拉菜单的子目录。不幸的是,我似乎无法在 xampp 中使用它。无法从 Vista Buttons 显示我的 javascript 菜单,现在我将我的站点的主目录移动到 htdocs 目录。

4

5 回答 5

3

Since XAMPP uses Apache you need to configure it to permit SSI.

To permit SSI on your server, you must have the following directive either in your httpd.conf file, or in a .htaccess file:

Options +Includes

This tells Apache that you want to permit files to be parsed for SSI directives. Note that most configurations contain multiple Options directives that can override each other. You will probably need to apply the Options to the specific directory where you want SSI enabled in order to assure that it gets evaluated last.

Not just any file is parsed for SSI directives. You have to tell Apache which files should be parsed. There are two ways to do this. You can tell Apache to parse any file with a particular file extension, such as .shtml, with the following directives:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page, and all links to that page, in order to give it a .shtml extension, so that those directives would be executed.

The other method is to use the XBitHack directive:

XBitHack on

XBitHack tells Apache to parse files for SSI directives if they have the execute bit set. So, to add SSI directives to an existing page, rather than having to change the file name, you would just need to make the file executable using chmod.

chmod +x pagename.html

According to Apache Tutorial: Introduction to Server Side Includes

于 2012-07-19T14:27:47.563 回答
2

我遇到了同样的问题,但我无法弄清楚我必须修改的确切位置以及哪些文件。因此,要修复它,请按照 XAMPP 本地主机服务器中的以下步骤进行操作。

  1. 转到您的:

    c:/xampp/apache/conf/httpd.conf
    
  2. 搜索:

    AddType text/html .shtml
    
  3. 添加以下两行:

    AddType text/html .html
    AddOutputFilter INCLUDES .html
    
  4. 转到Xampp 控制面板停止会话并重新启动

  5. 在浏览器中刷新页面并查看,虚拟包含将开始工作。

于 2015-07-07T15:58:47.543 回答
1

要回答您的第一个问题,您可以访问http://localhost/吗?如果是这样,那么 xampp 运行正常,您无需再做任何事情。

编辑:如果您想确保一切正常,请将 foo.html 放在 /xampp/htdocs 下,然后在http://localhost/foo.html的浏览器中访问它。如果您无法获取此页面,则 xampp 仍然无法正常运行。

在回答您的第二个问题时,无论是 HTML 还是 PHP 中的所有包含都是服务器端的。如果您正确安装了 xampp,那么您可以立即开始使用 PHP 并可以使用 PHP 中的包含函数(请注意,即使页面仅包含 HTML,如果您使用的是 PHP,它仍然必须具有 .php 扩展名) .

如果您更愿意在 .html 页面中使用 SSI,那么此链接可能会提供有关如何在 xampp 中设置和调试 SSI 的一些帮助。

此外,如果您还没有这样做,我建议您在安装了 Firebug 的 Firefox 中工作。Firebug 将处理您的大部分 JavaScript 调试需求。

最后一点,如果您移动了目录等,我首先要检查的是脚本标签上的 src 属性。

于 2008-11-23T17:08:16.920 回答
1

我发现要在 XAMPP 中使用包含功能,您的包含包含功能的页面需要具有扩展名“.shtml”,而包含的文件具有“.html”。大多数现代浏览器不需要 shtml 扩展,但 XAMPP 似乎需要。

.js 似乎是一样的。

于 2009-01-29T22:34:31.580 回答
0

您可能想查看 AMPstart 而不是 xampp-control。它有一些很好的能力,可以让您将站点文件夹放在 htdocs 之外,而不会弄乱 apache conf 的东西

于 2008-11-23T17:21:29.937 回答