When I try to enter [mydomain.com] I see the default version page:
Lumen (5.5.2) (Laravel Components 5.5.*)
When I try to enter [mydomain.com]/api/user I receive a 404 error.
My web.php looks as follows:
$router->get('/', function () use ($router) {
return $router->app->version();
});
$router->group(['prefix' => 'api'], function () use ($router) {
// show
$router->get('user', 'UserController@show');
});
What am I missing? Can anyone help?
I´m still not 100% sure why this behaviour occured, cause on the same server an additional lumen project worked even before my fix perfectly, but I have found the reason:
The problem depends on an issue with the rewrite engine. It´s quite easy to find out if you have the same problem. If you get a 404 on each route except the "/"
try out to add "index.php"
in your URL (e.g.: domain.com/index.php/user
instead of domain.com/user
). If now the route can be used you might check your apache config and change
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Additionally you can check if your rewirte engine works well by adding the following line to the .htaccess
inside the \public
folder of your lumen project:
<IfModule mod_rewrite.c>
Redirect 301 / https://google.com
[...]
If you´re not redirected to google while requesting any route you need to check your configuration.