Remove index.php from Magento Store URL

In this blog, we will see how to remove index.php from base URL of a Magento store.

To remove “index.php” from the web-site URL, the mod_rewrite module should be enabled on your server.

In case, mod_rewrite is not enabled, follow these steps:

  1. Run this command sudo a2enmod rewrite
  2. Edit your httpd configuration and write following lines
    <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
  3. Now, restart apache service using this command (the commands might change based on the OS that you use)
    sudo service apache2 restart

You need to following these steps:

  1. Log in to your Magento store admin and go to the Store ⇒ Configuration section. (In case of Magento 1, it’s System  Configuration)
  2. Then click on the Web tab in the leftside menu.
  3. Expand the Search Engines Optimization tab and set the Use Web Server Rewrites option to Yes.
    Search Engines Optimization
  4. Then, go to the Base URLs (Secure) tab and set the Use Secure URLs on Storefront option to Yes, too. Click on the Save Config button.
    Base URLs (Secure) ⇒ Use Secure URLs on Storefront
  5. Make sure your Secure and Unsecure base urls should end with “/”.