为什么我的服务器端包含 (SSI) 不工作?

Why isn't my Server Side Includes (SSI) working?

我正在制作一个网站,该网站位于带有 Apache 的 Amazon EC2 实例上,我正在尝试启用 SSI work/be,我已经上传了 .htaccess 文件和我想要的文件被包括在内等等。但是 SSI 仍然没有工作。为什么我的 SSI 不起作用?

我上传的所有文件都位于 /var/www/html,如果有帮助的话!

我的 .htaccess 文件中有 AddType text/html .shtml AddOutputFilter INCLUDES .shtml

我的 index.html 文件中的包含命令:<!--#include file="main_nav.shtml" -->.


main_nav.shtml:

<!--Main Nav-->
<header>
 <nav>
  <div class="main_nav">
  <a id="second_nav_bar" href="">Contact Me!</a>
  <a id="second_nav_bar" href="">About Me</a>
  <a id="second_nav_bar" href="">Search my site</a>


 <!--
  <div id="searchbox_div">
   <form action="" id="searchbox">
    <input id="search_input" type="search" name="searchmysite" placeholder="Search my Site!">
    <input type="submit" value="Search!">
   </form>
  </div>
 -->


  </div>
  
  <div id="logo">
   <h1 id="logo_jeff">JEFF</h1>
   <h1 id="logo_arries">ARRIES</h1>
   <h1 id="logo_website">WEBSITE</h1>
  </div>
  
  <div id="main_nav">
   <ul>
    <li><a class="main_nav" href="">Home</a></li>
    <li><a href="">Blog</a></li>
    <li><a href="">Trips</a></li>
    <li><a href="">Politics</a></li>
    <li><a href="">Pictures</a></li>
    <li><a href="">Videos</a></li>
    <li><a href="">Computer</a></li>
    <li><a href="">Misc</a></li>
   </ul>
  </div>
 </nav>
</header>

<!-- End Main Nav-->

这是我计算机上的文件(不提供文件)(只是为了直观地展示我的服务器的样子,见下文):

这是我的 Amazon EC2 服务器(提供文件)的终端屏幕截图,显示了文件和结构(见上文):


仅供参考。如果您想实时查看我的网站,请访问 jeffarries.com

如果您需要任何进一步的信息,请随时询问!


更新:


更新 2:

Main_nav.shtml:

<!--#include file="main_nav.shtml" -->

<!--Main Nav-->
<header>
 <nav>
  <div class="main_nav">
  <a id="second_nav_bar" href="">Contact Me!</a>
  <a id="second_nav_bar" href="">About Me</a>
  <a id="second_nav_bar" href="">Search my site</a>


 <!--
  <div id="searchbox_div">
   <form action="" id="searchbox">
    <input id="search_input" type="search" name="searchmysite" placeholder="Search my Site!">
    <input type="submit" value="Search!">
   </form>
  </div>
 -->


  </div>
  
  <div id="logo">
   <h1 id="logo_jeff">JEFF</h1>
   <h1 id="logo_arries">ARRIES</h1>
   <h1 id="logo_website">WEBSITE</h1>
  </div>
  
  <div id="main_nav">
   <ul>
    <li><a class="main_nav" href="">Home</a></li>
    <li><a href="">Blog</a></li>
    <li><a href="">Trips</a></li>
    <li><a href="">Politics</a></li>
    <li><a href="">Pictures</a></li>
    <li><a href="">Videos</a></li>
    <li><a href="">Computer</a></li>
    <li><a href="">Misc</a></li>
   </ul>
  </div>
 </nav>
</header>

<!-- End Main Nav-->

index.shtml:

<head>
<title>Home | Jeff's Website</title>

<link href="styles/main_navigation.css" type="text/css" rel="stylesheet" />
<link href="styles/body.css" type="text/css" rel="stylesheet" />
<link href="styles/main_content.css" type="text/css" rel="stylesheet" />


<!-- Icon code -->
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="/website_icons/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/website_icons/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/website_icons/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/website_icons/apple-touch-icon-144x144.png" />
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="/website_icons/apple-touch-icon-60x60.png" />
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="/website_icons/apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="/website_icons/apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="/website_icons/apple-touch-icon-152x152.png" />
<link rel="icon" type="image/png" href="/website_icons/favicon-196x196.png" sizes="196x196" />
<link rel="icon" type="image/png" href="/website_icons/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/png" href="/website_icons/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/website_icons/favicon-16x16.png" sizes="16x16" />
<link rel="icon" type="image/png" href="/website_icons/favicon-128.png" sizes="128x128" />
<meta name="application-name" content="&nbsp;"/>
<meta name="msapplication-TileColor" content="#FFFFFF" />
<meta name="msapplication-TileImage" content="/website_icons/mstile-144x144.png" />
<meta name="msapplication-square70x70logo" content="/website_icons/mstile-70x70.png" />
<meta name="msapplication-square150x150logo" content="/website_icons/mstile-150x150.png" />
<meta name="msapplication-wide310x150logo" content="/website_icons/mstile-310x150.png" />
<meta name="msapplication-square310x310logo" content="/website_icons/mstile-310x310.png" />
<!-- End Icon code -->



<!-- Chatrify Script-->
<script type='text/javascript'>
    var __ac = {};
    __ac.uid = "08c261285ca9db6acdaf945deef7cd7b";
    __ac.server = "secure.chatrify.com";

    (function() {
      var ac = document.createElement('script'); 
      ac.type = 'text/javascript'; 
      ac.async = true;
      ac.src = 'https://cdn.chatrify.com/go.js';
      var s = document.getElementsByTagName('script')[0]; 
      s.parentNode.insertBefore(ac, s);
    })();
 </script>


</head>


<body>
 
 
<!--#include file="main_nav.shtml" -->



<!-- Landing Beta Pop Up box -->

<div id="popup_div">
 <div id="popup_beta">
  <p id="popup_main_header">Welcome to my website!</p>
  <p id="popup_main_content">My site is currently under construction. &nbsp; I'm trying to get everything ready, working and online as soon as possible. &nbsp;But for the time being, there may be broken/grayed out links and random stuff that doesn't work properly. Thank you for your patience!</p>
  
  <a id="got_it_button"href="#" onclick="toggle_visibility('popup_div');">Got it!</a>
 </div>
</div>

<!-- End Landing Beta Pop Up box -->

<!-- Pop Up Email Form-->
<div id="popup_email_form_div">
 <div id="popup_email_form_div_content">
  <p>Contact Form</p>
  <form method="post" action=""></form>
 </div>
</div>

<!-- End Pop Up Email Form-->



<!--Welcome to jeff's website-->

<div>
 <h2 id="welcome">Welcome to my Website!</h1>
 
 <a href="#here_you_can_learn">
 <img src="pictures/down_arrow.png" id="down_arrow"/>
 </a>
</div>

<!-- End Welcome to Jeff's website-->

<!--right side nav-->

<aside>
 <p>this is aside</p>

</aside>


<!--Main Content-->

<div id="main_content">
 <h2 id="here_you_can_learn">Here you can learn about me and my adventures!</h2>

<!--Most Frequently visited pages: on left side of page-->
 <div id="most_frequent">
  <p class="heading">Most frequently visted pages!</p>
  
  
  
  <a href="" class="show_more_link"><p class="show_more">Show More</p></a>

 </div>
 
<!--Recent Activity: on the right side of page-->
 <div id="recent_activity">
  <p class="heading">Recent Activity</p>


  <p class="content">test</p>


  <a href="" class="show_more_link"><p class="show_more">Show More</p></a>
 </div>
</div>



<script type="text/javascript">

    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display = 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }

</script>


</body>

我的查找器 window 现在的截图:(不提供文件,但与服务器相同)

这个:

AddOutputFilter INCLUDES .shtml

…告诉 Apache 在 .shtml 文件中查找 SSI 指令。

您已将 SSI 指令 (<!--#include file="main_nav.shtml" -->) 放入 .html 文件而不是 .shtml 文件。