How to make MAMP recognize the .shtml extension and read server-side includes

Update (24 August 2011): Due to my recent “restart,” I wanted to see if these instructions still work with MAMP 2.0.1. I followed them as written and was able to get server-side includes working the first time with no issue.

Making MAMP recognize server-side includes is simple:

  1. Stop the MAMP servers.
  2. Open MAMP's httpd.conf (located at /Applications/MAMP/conf/apache/httpd.conf) in a plain text editor.
  3. Find the line DirectoryIndex index.html index.php and change it to DirectoryIndex index.shtml index.html index.php
  4. Uncomment the following two lines: AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
  5. Find the lines <Directory />
    Options Indexes FollowSymLinks
    AllowOverride All
    </Directory>
    and change to <Directory />
    Options Indexes FollowSymLinks
    Options +Includes
    AllowOverride All
    </Directory>
  6. Restart the MAMP servers.

6 thoughts on “How to make MAMP recognize the .shtml extension and read server-side includes

  1. Sigh, I’ve tried this so many times and can’t make it work. Uncommenting those 2 lines (lines 985 and 986 on my http.conf file), gives me an error processing the includes… Here’s an example of one of my includes:
    <!–#include file="/xx/xyz/ca_Menu3.html"–>

    Still tryin’!

  2. I’d say to triple check your code as you go, and make sure you aren’t using a cheap text editor since it might add weird hidden characters. And backup your original.

    Worked for me first try.

  3. Thanks for the comments!

    Sorry to hear about your’re having problems with this, Adam. I just got a new MacBook Pro, installed MAMP 2.0.1 and followed my own instructions to a line and it worked the first time with no problems.

    Good point, David! There’s no reason to restrict server-side includes to just the .shtml extension if you plan to make extensive use of them. However, this does mean that each .html file will require more processing, and so, if you serve a lot of static .html files that don’t have includes, there will be a slight performance hit.

  4. Hi There,

    Can you tell me which text editor you are using?

    I have used both textedit and dreamweaver to edit this file. I have followed the steps but I still get the “[an error occurred while processing this directive] ” error message.

    Thanks in advance.
    Kevin

  5. Hello Kevin,

    I use Textmate, but either TextEdit or Dreamweaver should do the trick. I plan to revisit this post shortly, so hopefully that will shed some light on the issue you’re having.

    Jeffrey

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>