Magento – Magento2.3 – How to remove index.php from dynamic URL

magento2

Magento 2.3.1 fresh install with sample data module.

In admin side

  • "Use Web Server Rewrite" : Yes
  • .htaccess is generated by default
  • rewrite mod is enable
  • server using php7.2 and apache2.4.38

virtual domain: http://magento2.local

  • http://magento2.local/index.php/category/product/view/id/260worked
  • http://magento2.local/category/product/view/id/260404 not found

Virtual file.

<Directory />
    Options Indexes MultiViews FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
</Directory>

I guess it was due to my Apache setup, but I cannot find where.
Any helps πŸ™

Thanks in advance..!

Best Answer

In your htaccess file, add the following

<IfModule mod_rewrite.c>
        RewriteEngine On

        # Removes index.php from ExpressionEngine URLs
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Related Topic