Enabling Server-Side Includes on Apache


Sometimes the documentation for the Apache Http Server is difficult to understand (or just bad altogether). One section that should be easier to understand is how to enable server-side includes. Therefore, I've translated that section into the following:
  1. Open /conf/http.conf
  2. Make sure the following line is already in the file: LoadModule include_module modules/mod_include.so
  3. Add the following line to the end of the file: AddType text/html .shtml
  4. Add the following line to the end of the file: AddHandler server-parsed .shtml
  5. Add the following line inside the <Directory /> tag: Options +Includes
  6. Save the file (http.conf)
  7. Restart the server
  8. Name your files that use the <!--#include file="..." -->
    directive with an .shtml extension
There's probably a lot more that is possible that I am leaving out, but this should get you exactly what you probably need. If you don't want to use the .shtml extension (and leverage the include directive in .html files, you can skip steps #3 & #8, but change step #4 from .shtml to .html. Realize, however, that all .html files on your site will have to go through the server parser, and, therefore, potential performance issues could occur.

0 comments:

Post a Comment

Aaron Hursman
Aaron Hursman is a passionate user-advocate who is lucky enough to do what he loves for a living. As a user experience architect, he applies user-centered design principles and techniques including user research, persona development, information architecture, storyboards, wireframes, prototyping, visual design, graphic design, interaction design, and usability. Aaron has a background in web development, enterprise applications, and the social web. At nGame, he is applying his craft to design and build the next generation of enterprise software. Aaron is available as a speaker and author upon request.
Disclaimer: The information in this website is provided "as is" with no warranties, and confers no rights. This website does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. Inappropriate comments will be deleted at the authors discretion. All instructions and code samples (if any, ever) are provided "as is" without warranty of any kind, either express or implied.