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

phpstorm: unable to access contact page

I have local setup and using XAMPP , phpstorm

I can access about page http://localhost:63342/TreehousePHP/

When I click on contact it is moving to http://localhost:63342/TreehousePHP/contact.html and getting 404 Not Found. Even same 404 error when I access http://localhost:63342/TreehousePHP/contact

$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();

here is my .htaccess

RewriteEngine On

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

screen shot link here

https://www.dropbox.com/s/8n64c0jhfyfbh7e/Capture.JPG?dl=0

Please help me. what is wrong here..

Benjamin Payne
Benjamin Payne
8,142 Points

Slims front controller, index.php, needs to be in the root directory along with .htaccess file. If /TreehousePHP is not the root directory of that site this will not work.

1 Answer

Thanks Benjamin. I have removed index.php from htdocs. It works now.

David Richied
David Richied
18,057 Points

I'm experiencing the same problem. Could you further explain your solution? Did you put index.php and .htaccess in the xampp folder? Thanks.