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:
- Stop the MAMP servers.
- Open MAMP's
httpd.conf(located at/Applications/MAMP/conf/apache/httpd.conf) in a plain text editor. - Find the line
DirectoryIndex index.html index.phpand change it toDirectoryIndex index.shtml index.html index.php - Uncomment the following two lines:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml - Find the lines
<Directory />and change to
Options Indexes FollowSymLinks
AllowOverride All
</Directory><Directory />
Options Indexes FollowSymLinks
Options +Includes
AllowOverride All
</Directory> - Restart the MAMP servers.
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’!
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.
This worked great for me, thank you!
PS If you’d like to also have includes in .html files, add use a .html on this line:
AddType text/html .shtml .html
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.
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
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