简体   繁体   English

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

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

I'm making a website, that is on a Amazon EC2 Instance with Apache, I'm trying to get SSI to work/be enabled, I've uploaded the .htaccess file and the file I want to be included, etc. But the SSI is still not working. 我正在建立一个网站,该网站位于使用Apache的Amazon EC2实例上,我正在尝试使SSI正常工作/启用,我已经上传了.htaccess文件和我想包含的文件,等等。但是SSI仍然无法正常工作。 Why doesn't my SSI work? 为什么我的SSI不起作用?

All of the files I uploaded are located at /var/www/html , if that helps! 我上传的所有文件都位于/var/www/html ,如果有帮助的话!

My .htaccess file has AddType text/html .shtml AddOutputFilter INCLUDES .shtml in it. 我的.htaccess文件中包含AddType text/html .shtml AddOutputFilter INCLUDES .shtml

My include command in my index.html file: <!--#include file="main_nav.shtml" --> . 我的index.html文件中的include命令: <!--#include file="main_nav.shtml" -->


The 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--> 

Here's my files on my computer (not serving the files) (just to give a visual of what my server looks like, see below): 这是我计算机上的文件(不提供文件)(只是为了直观显示服务器的外观,请参见下文): 在此处输入图片说明

And here's a terminal screenshot of my Amazon EC2 server (serving the files), showing the files and structure (see above): 这是我的Amazon EC2服务器(提供文件)的终端屏幕截图,显示了文件和结构(请参见上文): 在此处输入图片说明


FYI. 仅供参考。 My website is at jeffarries.com if you want to view it live. 如果您想实时查看我的网站,请访问jeffarries.com

If you need any further information, feel free to ask! 如果您需要任何其他信息,请随时询问!


Update: 更新: 终奌站


Update 2: 更新2:

Main_nav.shtml: 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: 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> 

Screenshot of what my finder window looks like now: (not serving the files, but the same as the server) 我的查找程序窗口现在的屏幕截图:(不提供文件,但与服务器相同)

发现者

This: 这个:

 AddOutputFilter INCLUDES .shtml 

…tells Apache to look in .shtml files for SSI directives. …告诉Apache在.shtml文件中查找SSI指令。

You have placed your SSI directive ( <!--#include file="main_nav.shtml" --> ) in a .html file instead of a .shtml file. 您已将SSI指令( <!--#include file="main_nav.shtml" --> )放在.html文件而不是.shtml文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM