Try to restart your server once.
Laravel API works locally, but throws 404 error on server
I am currently updating a Laravel API from 6.x to 10.x. I was able to use Laravel Shift successfully, and tested all changes locally. I am able to hit the API locally, and when I connect to the database on the Apache server the API runs on in production, I am able to successfully execute CRUD queries against it. However, when moving the changes to the Apache server, I am unable to hit the API on the server. I ensured that PHP was upgraded to 8.2, and when I run
php artisan route:list
all routes show up correctly. I have also cleared the caches and run composer update and php artisan migrate (for the database migrations that were changed while updating the API). All permissions look correct.
.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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I'm wondering if there is anything that I have missed with the Apache server configuration, and Google searches have yielded no results. Help please!
@gych I fixed it. The .htaccess file was not pointed to the correct directory. When I updated the .htaccess file and index.php with the correct file paths, everything worked. Thank you!
Please or to participate in this conversation.