INFORMATION

GET INVOLVED

Laravel on MAMP: How to fix the forbidden access error

If you are experiencing a "Forbidden" error in Laravel while using MAMP (or any other web server), here is how to resolve the problem.
How to fix Forbidden access error in Laravel while using MAMP.
If you are experiencing a “Forbidden” error in Laravel while using MAMP (or any other web server), here is how to resolve the problem.

 

The Most Common Resolution of the Problem

Copy the following code and insert it into the .htaccess file in your Laravel root directory:

				
					<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
				
			

 

Other Possible Issues

  1. Directory Permissions: Verify that the storage and bootstrap/cache directories have appropriate permissions.

  2. Virtual Host Configuration: Confirm proper configuration of virtual hosts in the web server settings.

  3. Document Root Configuration: Check if the document root in the web server configuration points to the public directory.

  4. MAMP Ports: Ensure MAMP is running on the correct ports, avoiding conflicts with other services.

  5. Check Laravel Logs: Review Laravel logs in the storage/logs directory for potential error messages.

  6. Check File Ownership: Confirm that files and directories are owned by the correct user.

  7. .htaccess RewriteBase: Adjust the RewriteBase in the .htaccess file if necessary.

  8. Clear Cache: Use Laravel commands to clear cache and routes.

  9. Update Composer: Keep dependencies up-to-date by running composer update.

After implementing changes, restart the web server and check for the resolution of the “Forbidden” error. If the issue persists, consult error logs for further insights.