I built a php site using the built in server. I experienced none of the problems I am now facing when using Apache.
Folder structure:
app -> index.php
controllers -> home.php
views -> home.php
I have Apache successfully serving the home page at "/" but any other page I visit returns a 404. Inside "index.php" is a "switch ($_SERVER['REQUEST_URI'])" statement. A visit to the URI called the controller which in turn calls the view:
switch ($_SERVER['REQUEST_URI'])
{
case '/':
home_controller::home();
break;
case '/signup':
signup_controller::signup();
break;
}
If I try to visit the "signup page" at "/signup" I get a 404. I'm not sure why this is the case. I don't know Apache that well but spent a lot of time trying to figure this out. Rewrite didn't fix the problem but I could have been doing it wrong. Any information would be much appreciated.
Edit 1 Modrewrite may solve the problem but it did not before. As stated I don't know Apache that well so finding the correct terminology may be tripping me up.
My PHP program takes the REQUEST_URI and has a router built in that matches on a switch statement. My logic was that any uri that goes to Apache would in turn go to PHP. I did nothing to make "/" work correctly. Not sure why I need to do something different to make "/signup" work.
Edit 2
I solved the problem.
try_files $uri /index.php$is_args$args;
I switched from Apache to Nginx and applied the line above. I was actually having two issues. The first was a database problem stopping the app from functioning correctly. The other was the line missing above.
This question was not a duplicate as "pretty urls" was not the answer. The problem was how Apache was routing my already made urls in php.
Thanks ippi for providing the link!