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/260 - worked
  • http://magento2.local/category/product/view/id/260 - 404 not found

Virtual file.

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

I guess it was due to my Apache setup, but I cannot find where. Any helps :(

Thanks in advance..!


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]
| improve this answer | |

You can remove the index.php in the frontend URLs performing the following steps in Magento's admin section:

In System -> Configuration -> Web -> Search Engines Optimizations, select YES.

Edit the /rootdir/.htaccess and uncomment the line by removing #:

RewriteBase /magento2/

In my case the subdirectory Magento is in is called magento2, so change it to your subdirectory path if it is different.

If above solution is not work then add below line in your .htaccess file

AddHandler application/x-httpd-php73 .php .php5 .php4 .php3
| improve this answer | |
  • I try all solutions which searched from google, however none of them worked!!! – Nam TU Hai May 2 '19 at 9:35

Go to System -> Configuration -> Web > Search Engine Optimisation> Web Server Rewrites : YES.

You should make sure that your Secure and Unsecure base urls end with “/”. Now edit your .htaccess of magento root folder and add below code

RewriteEngine On
RewriteBase /magento2/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
| improve this answer | |

I had this same issue and fixed it by doing the following in .htaccess:

#RewriteBase /magento/


RewriteBase /

Make sure you have selected Yes to activate

Admin > Stores > Configuration > General Tab > Web > Search Engines Optimization = select Yes for Use Web Server Rewrites.

Job Done!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.