It sounds like your URL rewriting isn't working. If you add index.php
to the URL right before the /api
does it work?
For example, yourdomain.com/api
would become yourdomain.com/index.php/api
and if the second URL works, then rewriting isn't working.
If your rewriting isn't working, but you have the .htaccess
file in your public
directory, then you probably need to allow overrides in your Apache configuration. Here is an example virtual host configuration for Lumen on Ubuntu.
I've marked the lines you need to change. Change the first and third to point to the public
directory in your website's directory. Then change the second line to the domain name you're using with your website.
<VirtualHost *:80>
DocumentRoot "/var/www/lumen/public" # Change this line
ServerName yourdomain.com # Change this line
<Directory "/var/www/lumen/public"> # Change this line
AllowOverride All # This line enables .htaccess files
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You'll need to restart Apache for these settings to take effect.
A Better Way
Enabling the .htaccess
file should work, but using .htaccess
slows down your site some. The best solution is to put the contents of the .htaccess
file in your virtual host, and then disable .htaccess
files.
The example virtual host configuration for that looks like this:
<VirtualHost *:80>
DocumentRoot "/var/www/lumen/public" # Change this line
ServerName yourdomain.com # Change this line
<Directory "/var/www/lumen/public"> # Change this line
# Ignore the .htaccess file in this directory
AllowOverride None
# Make pretty URLs
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>
Once again, you'll need to restart Apache for these settings to take effect.