I'd like to create a Front Controller to process all requests to my PHP site. So I created a routes.php in my site root: http://localhost:81/site/
My site is hosted on apache in my local machine, and /site is a alias configured in apache httpd.conf
.
And configured .htaccess with the FallbackResource directive:
FallbackResource /routes.php
But then I get a 404 error to any URL I access.
So I changed to: (I'm on Windows)
FallbackResource \routes.php
It works when I access http://localhost:81/site/mycontroller
, it calls routes.php, but when I tried to call http://localhost:81/site/mycontroller/myaction
, I get an error. Exploring the log files, I discovered that apache is searching for routes.php in a /mycontroller directory (Which does not exists)
How do I Configure FallbackResource in a way that routes.php in site root will be called regardless of the structure of the URL used?
The documentation says,
and then gives
FallbackResource /blog/index.php
as the example in this case.So for your situation, you would need
/site/routes.php
here then.