Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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