Search code examples
php.htaccessmampfat-free-framework

How to setup F3 .htaccess with MAMP on Mac?


I recently switched my OS from Windows to Mac and I am having a problem running locally. I installed MAMP under /Applications/MAMP.

/Applications/MAMP/htdocs/.htaccess file:

RewriteEngine On
RewriteBase /abc/

# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule (.+\.(?:gif|png|jpe?g|css|js|woff|ttf))$ /abc/$1 [NC,L]
RewriteRule .* /abc/index.php [L]

This fully worked on my Windows environment but now it only loads some of the resources and throws the following error:

Not Found (404) - HTTP 404 (GET /index.php)

array(1) {
[0]=>
  array(6) {
    ["file"]=>
    string(42) "/Applications/MAMP/htdocs/abc/index.php"
    ["line"]=>
    int(27)
    ["function"]=>
    string(3) "run"
    ["class"]=>
    string(4) "Base"
    ["type"]=>
    string(5) "->"
    ["args"]=>
    array(0) {
    }
  }
}

My Network shows it is trying to GET localhost:8888/abc/index.php but it is receiving a 404, even though that is the correct path.

I am fairly certain this is an error with my .htaccess file because my images and fonts are loading correctly.


Solution

  • Translating my comments into an answer.

    Looks like the error is due to the fact the index.php is not loading by default for a folder. You need to place this line at top of your .htaccess.

    DirectoryIndex index.php