xampp 包括不工作

发布于 2024-07-09 22:38:11 字数 426 浏览 4 评论 0 原文

首先,我如何知道我的 html 文件是否在 Xampp 的本地主机上运行? 是否有关于如何管理文件/目录并使其在 htdocs 下工作的教程? 有关于如何设置的好的教程吗?

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

First off, how do I know if my html file is running on localhost in Xampp?
Is there a tutorial on how to manage files/directories and get that all working under htdocs?
Is there a good tutorial on how to setup includes?

I want to use "includes" in Xampp with my html.
Can I use both html includes AND php includes?
Do I have to put shtml?
Can I use shtml, html, htm, and php includes?
Do they have to be in an includes directory that is a subdirectory right under htdocs?
Can I reference includes in some other subdirectory?
My site will have over 100 pages, and I am trying to do "experiments" with different versions until I am happy. So, I have subdirectories for the various drop down menus. Unfortunately, I don't seem to be able to get this working in xampp.
Having trouble getting my javascript menus from Vista Buttons to show up, now that I moved my main directory for my site to the htdocs directory.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

海之角 2024-07-16 22:38:11

由于XAMPP使用Apache,您需要将其配置为允许SSI

要在您的服务器上允许 SSI,您的 httpd.conf 文件或 .htaccess 文件中必须包含以下指令:

选项+包括 
  

这告诉 Apache 您希望允许对文件进行 SSI 指令解析。 请注意,大多数配置包含多个可以相互覆盖的选项指令。 您可能需要将选项应用到您希望启用 SSI 的特定目录,以确保最后对其进行评估。

并非所有文件都会被解析为 SSI 指令。 您必须告诉 Apache 应该解析哪些文件。 有两种方法可以做到这一点。 您可以使用以下指令告诉 Apache 解析具有特定文件扩展名(例如 .shtml)的任何文件:

AddType text/html .shtml 
  AddOutputFilter 包括 .shtml 
  

这种方法的一个缺点是,如果您想将 SSI 指令添加到现有页面,则必须更改该页面的名称以及指向该页面的所有链接,以便为其提供 .shtml 扩展名,以便执行这些指令。

另一种方法是使用 XBitHack 指令:

XBitHack 上 
  

XBitHack 告诉 Apache 解析文件中的 SSI 指令(如果它们设置了执行位)。 因此,要将 SSI 指令添加到现有页面,您只需使用 chmod 使文件可执行,而无需更改文件名。

chmod +x pagename.html 
  

根据 Apache 教程:服务器端包含简介

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

失与倦" 2024-07-16 22:38:11

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

  1. 转到您的:

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

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

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

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

I have faced the same issue but I was not able to figure out where exactly I have to modify and which files. So to fix it follow the below steps in XAMPP Localhost server.

  1. Go to your:

    c:/xampp/apache/conf/httpd.conf
    
  2. Search for:

    AddType text/html .shtml
    
  3. Add the below two lines:

    AddType text/html .html
    AddOutputFilter INCLUDES .html
    
  4. Go to Xampp Control Panel and stop the session and restart again.

  5. Refresh the page in browser and see, the virtual includes will start working.

酒解孤独 2024-07-16 22:38:11

要回答您的第一个问题,您可以访问 http://localhost/ 吗? 如果是这样,则 xampp 运行正确,您无需执行任何其他操作。

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

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

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

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

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

To answer your first question, can you access http://localhost/? If so, then xampp is running correctly and there is nothing more that you need to do.

EDIT: If you want to ensure that things are working correctly, place foo.html under /xampp/htdocs and then access it in a browser at http://localhost/foo.html. If you can't get this page then xampp still isn't running correctly.

In answer to your second question, all Includes whether in the HTML or within PHP are server side. If you have xampp installed correctly, then you can begin working in PHP immediately and can use the include functions within PHP (please note that even if a page only contains HTML, if you're using PHP it must still have a .php extension).

If you would rather use SSI in your .html pages, then this link might provide some help on how to set up and debug SSI in xampp.

Additionally, if you are not already doing so I would recommend that you work in Firefox with Firebug installed. Firebug will handle most of your JavaScript debugging needs.

As a final note, if you've moved directories and the like, the first thing I would check would be the src attributes on your script tags.

ま昔日黯然 2024-07-16 22:38:11

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

.js 似乎是一样的。

I found out that for includes to work in XAMPP your page with the include function needs to have the extension '.shtml' while the included file has '.html'. Most modern browsers don't require the shtml extension but XAMPP seems to.

.js seems to be the same.

花开半夏魅人心 2024-07-16 22:38:11

您可能想查看 AMPstart 而不是 xampp-control。 它有一些很好的功能,允许您将站点文件夹放置在 htdocs 之外,而不用乱搞 apache conf 的东西

You might want to look at AMPstart instead of xampp-control. It has some nice ability to allow you to place site-folders outside of htdocs w/o messing around with apache conf stuff

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文