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
Ben Goldman
14,626 PointsRequire_once() Problem
I just completed the Enhancing A Simple PHP Application course. I have moved all of my files for the Shirts4Mike project back into a folder called "shirts4mike" within my htdocs folder. I updated my config file so that both url and root paths are configured like this:
define("BASE_URL","/shirts4mike/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/shirts4mike/");
It's worked perfectly for every page except for my shirts listing page. When I try to view that page I get a 404 error. I think it must be because the link to the config file isn't working.
require_once("../inc/config.php");
Which seems strange to me because it works on all of the other pages. I have tried various configurations for that link, but nothing works. Hoping someone can help me out.
Thanks!
Ben Goldman
14,626 PointsSure, Mario.
3 Answers
Mario Blokland
19,750 PointsOk, you are definitely pointing to the right location then :-). The link to the config file should work properly also if you didn't change anything there.
Did you apply the changes to the RewriteRules for the new location in the .htaccess file? I think you may forgot that, since you get no php error but a 404 error (I assume you didn't cut the shirts.php out of the shirts folder).
Ben Goldman
14,626 PointsThat's what it is. I forgot about the .htaccess file. I just need to work out the new rewrites. What a pain.
Thanks, man.
Mario Blokland
19,750 PointsYou are welcome Ben :-)
Ben Goldman
14,626 PointsIf anyone else comes across this post with the same issue, just know that all I had to do - in addition to the updates shown in my initial post - was to update the .htaccess file. Specifically, the two RewriteRules that point to the shirts listing page and the individual shirt details pages. Since I added my project to a new subfolder, I had to include the new folder name, "/shirts4mike/", just before "/shirts/" on the second part of the Rule that tells the browser where to redirect to. Hope that wasn't too confusing.
Mario Blokland
19,750 PointsMario Blokland
19,750 PointsHi Ben,
could you please paste the url from the page of the 404 error in here?