nikic / FastRoute

Fast request router for PHP
Other
5.12k stars 445 forks source link

url NOT FOUND in laragon #228

Closed mofizul21 closed 3 years ago

mofizul21 commented 3 years ago

Hi,

Thanks for your awesome work.

Here is my code:

$dispatcher = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) { $r->addRoute('GET', '/', 'views/home.php'); $r->addRoute('GET', '/login', 'views/login.php'); });

Here homepage (https://smsecomdebug.test) is working fine. But when I'm trying to visit https://smsecomdebug.test/login, I see: Not Found The requested URL /login was not found on this server.

I'm using Windows 10 64bit, with Laragon PHP v7.4.

Why do I see the problem? Is it a problem with Windows, Laragon, or another?

Thanks.

Filip785 commented 3 years ago

Just stumbled across similar issue. Make sure you have .htaccess in the root of your project with the following content in order to redirect all your requests to the index.php:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [QSA,L]
lcobucci commented 3 years ago

As @Filip785 pointed out, this seems to be related to how the path is interpreted by your web server. Using .htaccess is only for Apache, check which web server you plan to use and how to forward things properly to PHP-FPM.

Closing here as invalid.