Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Slim Basics & Twig Templates Including & Running Slim

Nick Calabro
Nick Calabro
16,335 Points

After adding .htaccess error 500

Everything was great. Added the .htaccess file and now getting errors.

RewriteEngine On

# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

this is the snippet given in the video. I've even tried changing the RewriteBase so something like RewriteBase /root I'm running MAMP, the document root is a directory up, the index.php lives in Sites/composer/

2 Answers

Aamnah Akram
Aamnah Akram
17,549 Points

You might have to edit Apache's httpd.conf file in your MAMP install. There is a line that says AllowOverride None. You need to change it to AllowOverride All.

The location for the httpd.conf in MAMP (OS X) is at: /Applications/MAMP/conf/apache/httpd.conf

StackOverflow: How to get .htaccess to work on MAMP

Nick Calabro
Nick Calabro
16,335 Points

This really feels like it's going to work. But, do you think it'll mess with the previous settings? I don't want other projects to be ruined now since I'm tinkering with this. Thanks

Aamnah Akram
Aamnah Akram
17,549 Points

If you are afraid of messing up the .htaccess file, you can always make a copy first :) If it doesn't work, revert back to your working copy.

Hello,

Maybe you need to install Slim v 2. , rather than the current version.

Edward C. Young
Edward C. Young
10,323 Points

This worked for me. Use Composer to install the last version of the 2.0 branch, which as of now is 2.6.2