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 trialMartin Balon
43,651 PointsCan anyone help me with this?
Using the HTTP Foundation package from Symfony, redirect to "/not_found.php" with an "HTTP_NOT_FOUND" response.
<?php
require __DIR__ . '/vendor/autoload.php';
//add redirect here
1 Answer
Simon Coates
28,694 Pointsit seemed to pass with:
<?php
require __DIR__ . '/vendor/autoload.php';
//add redirect here
$response = \Symfony\Component\HttpFoundation\Response::create(
null, \Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND, ['Location' => "/not_found.php"]);
$response->send();
exit;
(FYI, often helpful to look in the forum at previous questions on a task. That's where I found this code.)
Martin Balon
43,651 PointsMartin Balon
43,651 PointsHi Simon, thanks mate. I searched the forum for same question and found two but the answers weren't really helpful. This code works. I did basically same thing - only I used a function and passed it a parameter $path and then called the function - it should work exactly same way but code challenge didn't accept my code. Once again thanks for you help and have a good day!