如何在 Mac 上使用 MAMP 设置 F3 .htaccess?

How to setup F3 .htaccess with MAMP on Mac?

我最近将我的 OS 从 Windows 换成了 Mac,我在本地遇到了问题 运行。我在 /Applications/MAMP.

下安装了 MAMP

/Applications/MAMP/htdocs/.htaccess 文件:

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/ [NC,L]
RewriteRule .* /abc/index.php [L]

这完全适用于我的 Windows 环境,但现在它只加载了一些资源并抛出以下错误:

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) {
    }
  }
}

我的网络显示它正在尝试 GET localhost:8888/abc/index.php 但它收到 404,即使那是正确的路径。

我相当确定这是我的 .htaccess 文件的错误,因为我的图像和字体加载正确。

将我的评论转化为答案。

看起来错误是由于 index.php 默认情况下没有加载文件夹。您需要将此行放在 .htaccess 的顶部。

DirectoryIndex index.php