0

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
</Directory>

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

Thanks in advance..!

7
  • Can you please show the path, which you have mentioned in your virtuel domain config file?
    – Saphal Jha
    Commented May 2, 2019 at 9:32
  • @SaphalJha /etc/apache2/sites-available/magento.local.conf
    – Nam TU Hai
    Commented May 2, 2019 at 9:33
  • @NamTUHai I mean to say DocumentRoot like : "/var/www/html/magentoroot"
    – Saphal Jha
    Commented May 2, 2019 at 9:35
  • @SaphalJha /home/magento2/public_html/magento2 , b/c virtual setup, I use /home/magento2/public_html instead of /var/www
    – Nam TU Hai
    Commented May 2, 2019 at 9:36

5 Answers 5

3

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>
1

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
1
  • I try all solutions which searched from google, however none of them worked!!!
    – Nam TU Hai
    Commented May 2, 2019 at 9:35
1

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]
0

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

#RewriteBase /magento/

to

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!

0

Run the below commands if you are facing an index.php issue while opening admin.

php bin/magento config:set web/seo/use_rewrites 1

php bin/magento c:f

1
  • Please don't use quote formatting if you are not quoting something. See the help page on formatting: magento.stackexchange.com/help/formatting. The > character is for quoting, not emphasis. This is a code block, so code-block formatting is exactly what is needed here. Commented Mar 12 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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