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 trialMycah Krason
15,184 PointsServer recognizes index.php file, but doesn't recognize any of the twig templates.
Hey, so the php website works completely fine on my local host. However, when I switch the files to my web server, I'm only able to pull up the index.php, but none of the links seem to work. Does anyone have any ideas as to what could be causing this?
5 Answers
Cena Mayo
55,236 PointsHi Mycah,
Do you have Twig installed on your host? Digital Ocean has a pretty good tutorial on installing and configuring Twig on a VPS.
Best, Cena
Mycah Krason
15,184 PointsThanks for the response, but I already have it installed through composer. I went through the entire "build a website with php" tutorial on my local host and every thing was fine, but for some reason when I try to do the same thing on my web server, it doesn't work. The index.php file loads in the browser, but none of the links work.
Cena Mayo
55,236 PointsSo to clarify, you have Twig installed on both your local host and your web server?
Mycah Krason
15,184 PointsOhhhh, so I decided to re-do the tutorial again, and I'm seeing that the .htaccess file is the part that isn't working. The file is spelled correctly and the notes from the video are copied directly into the file. Any ideas on why it wouldn't work?
Ted Sumner
Courses Plus Student 17,967 PointsJust to clarify, Twig is not installed on the server per se. It is in the vendor file that would be uploaded with the rest of the page assuming it is installed through composer, which it was.
Without seeing any code or the contents of the .htaccess file, it is impossible to troubleshoot.
It is important to note that Slim was recently updated, so if you are using Slim and use the most current version (3.?), it is significantly different than the course here, which is based on 2.6. To look a that issue, we need to see the composer.json file and your index.php code.
Mycah Krason
15,184 PointsThank you guys for your help! I turns out it was an issue on my server with the apache2.conf file. I needed to change part of the file where it says "Directory /var/www/" from "AllowOverride none" to "AllowOverride All" so it looks like this...
<Directory /var/www/> Options Indexes FollowSymLinks<br> AllowOverride All<br> Require all granted </Directory>