How to Remove Index.php from URL in Magento

How to Remove Index.php from URL in Magento

From the below two URLs, which one would you consider more readable, SEO-friendly and user-friendly?

http://meetanshi.com/index.php/magento-extension

OR

http://meetanshi.com/magento-extension

Shorter, the better. Isn’t it?

According to Google, the site’s URL structure should be as simple as possible. Additionally, the URLs with a structured hierarchy are preferred by GoogleBot as it makes the crawling throughout the site easier.

However, the default Magento and Magento 2 offers URLs with a lingering “index.php” and it is recommended to remove it.

Other benefits of short and simple URLs are:

  • Affects CTR. Users may examine the URL to decide whether to click or not.
  • Improved anchor text link juice flow
  • A minor ranking factor

Magento surely is the best platform for E-commerce stores but for the SEOs like me, the pesty index.php can be a nightmare!

So, here’s the method to remove index.php from URL in Magento

Get simple and short URLs without index.php with these easy steps:

Note: This method only works if mod_rewrite is enabled. The configuration for Magento 2 is in accordance with the Magento 2.3.0 version.

Steps to Remove Index.php from URL in Magento:

For Magento 2:

  1. Log in to Admin panel
  2. Navigate to Stores > Configuration > General > Web
  3. Expand the Search Engine Optimization section
  4. Set “yes” to Use Web Server Rewrites option.1_enable use web server rewrite
  5. Further, expand the Base URLs (Secure) section
  6. Set “yes” to Use Secure URLs on Storefront3_M2 secure frontend urls
  7. Save the configuration

For Magento 1,

  1. Log in to Admin Panel
  2. Navigate to System > Configuration > General > Web
  3. Expand the Search Engines Optimization section
  4. Set “yes” to Use Web Server Rewrites option.
  5. Expand the Secure tab
  6. Set “yes” to Use Secure URLs in Frontend2_Magento 1_remove index.php

Follow the above steps for your Magento version.

Note: If you still have an issue in removing the index.php, use a .htaccess File to Rewrite the URLs

Create a .htaccess file in the Magento installation folder to compliment the configuration within your admin panel, and this will actually rewrite the URLs. Choose the applicable .htaccess version below.

If your Magento store is installed in root (public_html), use this:

If your Magento store is installed in a subfolder (public_html/shop), use this:

For the programmatic method of URL Rewrite in Magento 2, check here.

Hope it helps.

Please feel free to use the Comments section below if you have any doubts in the above method.

Thank you!

 

5
(based on 6 Reviews)

Shivbhadrasinh Gohil is the Wizard of Light Bulb Moments at Meetanshi. He is a Digital Marketer and started optimizing Magento stores since 2010. He has also founded 2 successful Magento Agencies since 2014. When not working, you can find him reading books or playing with his daughter.

Leave a Reply