Index.php routing not working

Hi there, I’ve been trying to access routing using my index.php, but only one route (to “/”) works.
My site address: https://juniordev-task.000webhostapp.com/

How my index.php looks like:
index

What happens after I try to access https://juniordev-task.000webhostapp.com/addproduct:

How my folder structure looks like:

How my Router class looks like:

I can’t figure out why the code in the Router class is not executed the way I expect it to.
On my local server, everything works fine.

Any ideas?

Hi! You may need to redirect all incoming requests to index.php.

Add the following rules to .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L,QSA]

You may want to check out this answer: .htaccess - Redirect all to index.php using htaccess - Stack Overflow.

1 Like