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

Internal Server Error (Using ubuntu server / apache2 in userdir)

Hello all! I am getting stuck. when adding my .htaccess file. Apache is returning with

Internal Server Error    

The server encountered an internal error or misconfiguration and was unable to complete your request.    

Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.    

More information about this error may be available in the server error log.

My .htaccess file

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 /home/admini/public_html/me/    


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

I have tried: to add the "RewriteBase" with and without the absolute dir path as listed above to chmod 777 (not sure if that is a good idea) the .htaccess file

Using ubuntu server here is the output of uname -a

Linux linuxbox 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

apache2 -v

Server version: Apache/2.4.7 (Ubuntu)
Server built:   Mar 10 2015 13:05:59

php -v

PHP 5.5.9-1ubuntu4.9 (cli) (built: Apr 17 2015 11:44:57) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

If you need more information please let me know.

**Update June 20, 2015 1:11 PM **

I realized I needed to install a2enmod rewrite. So I installed it. and it appears to be "functioning" but not as expected.

Here is the dir tree of my public_html folder

┌─[admini@linuxbox][~/public_html]
│ [13:16:45   Sat Jun 20]
└─> tree -L 2
.
├── index.php
└── me
    ├── app.log
    ├── app.txt
    ├── composer.json
    ├── composer.lock
    ├── index.php
    └── vendor

and my .htaccess file is

RewriteEngine On
RewriteBase /~admini/    

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

when i navigate to

http://10.0.0.30/~admini/me/name/foobar

My browser returns and renders the file contents of

http://10.0.0.30/~admini/index.php masked with http://10.0.0.30/~admini/me/name/foobar

So it appears the rewrite engine is doing some work, but not as expected.

Any advise for next steps??

4 Answers

I ran into this error and it was a local machine config error. I am trying to remember what it was, though.

Edit: My error was slightly different on second thought. When rewrite rules were first introduced in a course here they mentioned that the server had to allow it. I will find and post that video, although they do not say how to change that on the server.

Resolved the issue by using this as my .htaccess file

RewriteEngine On    

RewriteBase /~admini/me/    

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

Resolved the issue by using this as my .htaccess file

RewriteEngine On    

RewriteBase /~admini/me/    

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