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 trialabdi ali
10,920 Pointscontact.html is not working but index.html works any one help!! what is wrong with my code
<?php
require __DIR__ . '/vendor/autoload.php';
// $log = new Logger('name');
// $log->pushHandler(new StreamHandler('app.log', Logger::WARNING));
// $log->addWarning('hello niba ');
// During instantiation
$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();
?>
18 Answers
Dean Friedland
2,453 PointsPlease click link below for answer:
Ted Sumner
Courses Plus Student 17,967 PointsIf your project is in a folder in your localhost environment, then you need localhost/folder/about.html.
Logan Connor
3,023 PointsThank you!
Ted Sumner
Courses Plus Student 17,967 PointsYou cannot render index.html because you have index.php. The project has the main landing page as about.html. Try changing index.html to about.html. If you really have index.html in your file tree, try changing its name to about.html as well.
abdi ali
10,920 Pointsthanks for the response it is working now but when i click the about page is going dead 404 not found the file
abdi ali
10,920 Pointsi tried the link to about.html <a href="about.html">it is still going dead end it is not working
abdi ali
10,920 Pointsif i enter this url localhost/ it is working ok but localhost/about.html it is not working
abdi ali
10,920 Pointsi modified the link to <a href="about.html">
abdi ali
10,920 Pointsokey solved!! but one more problem localhost/contact is not working
abdi ali
10,920 Points'''php <?php
require DIR . '/vendor/autoload.php';
// $log = new Logger('name'); // $log->pushHandler(new StreamHandler('app.log', Logger::WARNING)); // $log->addWarning('hello niba ');
// During instantiation $app = new \Slim\Slim();
$app->get('/', function() use($app) { $app->render('about.html'); });
$app->get('/contact', function() use($app) { $app->render('contact.html'); });
$app->run();
?>
'''
abdi ali
10,920 Points<?php
require __DIR__ . '/vendor/autoload.php';
// $log = new Logger('name');
// $log->pushHandler(new StreamHandler('app.log', Logger::WARNING));
// $log->addWarning('hello niba ');
// During instantiation
$app = new \Slim\Slim();
$app->get('/', function() use($app) {
$app->render('about.html');
});
$app->get('/contact', function() use($app) {
$app->render('contact.html');
});
$app->run();
?>
Dean Friedland
2,453 Pointssame issue
Dean Friedland
2,453 PointsSame issue. I hit "preview workspace" and the page comes up fine but if I click on either heading tab (index.html or contact.html) it goes 404 :(
Dean Friedland
2,453 Points''' <?php require DIR . '/vendor/autoload.php'; date_default_timezone_set ('America/New_York');
//$log = new Monolog\Logger('name'); //$log->pushHandler(new Monolog\Handler\StreamHandler('app.txt', Monolog\Logger::WARNING)); //$log->addWarning('Foo');
$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(); '''
Dean Friedland
2,453 Points<?php
require __DIR__ . '/vendor/autoload.php';
date_default_timezone_set ('America/New_York');
//$log = new Monolog\Logger('name');
//$log->pushHandler(new Monolog\Handler\StreamHandler('app.txt', Monolog\Logger::WARNING));
//$log->addWarning('Foo');
$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();
Ted Sumner
Courses Plus Student 17,967 PointsHere is a link to a post I did when I took this course. I think it discusses the issues and extent of the solutions that I discovered.
https://teamtreehouse.com/community/inconsistent-routing-and-helper-variable-output
Dean Friedland
2,453 PointsThanks but I found out from another member that information had changed and had not been updated in the video. I had to change two naming conventions on the contact and index files. Then it worked.
Ted Sumner
Courses Plus Student 17,967 PointsPlease post the solution here or mark the best answer.
abdi ali
10,920 PointsDean Friedland post your solutions so that i can see what changed
Nikhil Khandelwal
9,371 PointsI have tried nearly everything what all the answers were saying including Dean Friedland answer. but nothing is working for '/contact'.
tried changing to /contact, contact in <a> tags in html files but none working for /contact rendering.
$app->get('/contact', function() use($app) { $app->render('contact.html'); });