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 & Rendering

Damian Saunders
Damian Saunders
23,000 Points

Getting 404 error on the contact.html link

Hi, In the Including and rendering module of this course I' getting a 404 error, page not found error when clinking the contact link.

The index.html page is working as expected.

I'd appreciate it of someone could have a look at this as I'm lost...it all looks exactly the same as the code in the lesson.

Here's my code...

<?php

require __DIR__ . '/vendor/autoload.php';
date_default_timezone_set('America/New_York');

//$log = new Logger('name');
//$log->pushHandler(new StreamHandler('app.txt', Logger::WARNING));
//$log->addWarning('Oh Nos');

$app = new \Slim\Slim();

$app->get('/', function() use($app){
  $app->render('index.html');
});

$app->get('/contact', function() use($app){
  $app->render('contact.html');
});

$app->run();

My .htaccess file is as follows;

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]

Appreciate any assistance.

Thanks Damian

Damian Saunders
Damian Saunders
23,000 Points

Ah...ok, the links in the menu give the 404 error, but modifying the URL string works. Guess I jumped the gun a little and the menu links will be addressed further into the course...