I am using Lumen for the first time. I placed my lumen files in folder Test and kept the folder inside /var/www/html path in server. My PHP version is 7.4.3
I have the following routes:
$router->get('/key', function() {
return str_random(32);
});
$router->get('/', function () use ($router) {
return $router->app->version();
});
Below is my htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
But whenever I try to access http://xx.xxx.xxx.xxx/Test/public/key it shows
The requested URL was not found on this server.
But if I try to access http://xx.xxx.xxx.xxx/Test/public/ it returns me
Lumen (5.7.8) (Laravel Components 5.7.*)
How can I make all other routes also to work?
2
Answers
I searched for < Directory /var/www/ > in /etc/apache2/apache2.conf file and changed the below
to
and restarted the apache. It solved my issue.
It seems rewrite rule is disabled
sudo a2enmod rewrite
sudo service apache2 restart