🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Remove Index.php from URL in Magento

By Sanjay JethvaUpdated on May 22, 2025 3 min read

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.

Web Server Rewrites option in Magento store configuration

5. Further, expand the Base URLs (Secure) section

6. Set “yes” to Use Secure URLs on Storefront

Use Secure URLs on Storefront option in Magento store configuration

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 Frontend

2_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:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

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

RewriteEngine On
RewriteBase /shop/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]

For the programmatic method of URL Rewrite in Magento 2, check our blog post.

Hope it helps.

Thank you!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.