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
    and change to <Directory />
    Options Indexes FollowSymLinks
    Options +Includes
    AllowOverride All
  6. Restart the MAMP servers.

18 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.

  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.


  6. It seems simple enough but it’s not working for me. I get this message in the browser when I start the site from MAMP: “Forbidden You don’t have permission to access / on this server.”

  7. I got it working with XbitHack, which required a couple fewer changes to your httpd.conf

    Options +Includes
    AddType text/html .shtml (if you want to use .shtml extensions to differentiate between includes/non-includes, optional)
    XBitHack on

    Downside, you might need to use terminal to chmod -R +x *.html on the directory where these files exist on your Mac.

  8. Pingback: Configurar MAMP para las extensiones .shtml | ¿y por qué no?

  9. Thank you! I have been frustrated with this issue for longer than I care to admit. Finally find a solution here. But I am now but a month or so away from converting to Joomla CMS anyway. lol

  10. I too had an issue with this not working for me.
    The AddType line at instruction #4 had to have all of the following before it worked as per Andrew K Kirk post.

    [MAMP v2.2]
    [PHP v5.5.3]

    AddType text/html .shtml
    AddHandler server-parsed .shtml
    AddType text/html .html
    AddOutputFilter INCLUDES .html
    Options +Includes

Leave a Reply