Magento 2 如何删除 url 中的 index.php?

Mageto2 how to remove index.php in url?

我已经在本地安装了M242。 Docroot 是 /pub。除首页外所有页面均显示 404。我只是意识到 url 必须包含 index.php 才能正常工作。我如何删除 url 中的 index.php.htaccess 文件的内容是默认的。抱歉,我不能 post 因为在 post

中限制了字符

这是我的演示:https://imgur.com/a/pk7axDf

我的系统:

Ubuntu 20.04
Apache 2.4.41
Magento 2.4.2
PHP7.4

我仔细查看配置后找到了原因。原因是站点配置不允许覆盖然后 .htaccess 无法正常工作。
我只是 运行 sudo nano /etc/apache2/sites-available/mm.conf(mm.conf 是 apache2 站点配置,你可以将它替换为你的站点 conf)并更新它的内容

之前:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mm.test
    ServerAlias mm.test
    DocumentRoot /var/www/mm/pub
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

之后:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mm.test
    ServerAlias mm.test
    DocumentRoot /var/www/mm/pub
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/mm/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>