How to remove index.php when we enter manually in the URL

My store path is /var/www/html/testfolder/



Add this in your .htaccess after RewriteEngine on

RewriteCond %{THE_REQUEST} ^.*/index.php     
RewriteRule ^(.*)index.php$ https://domain.com/$1 [R=301,L]

Change domain.com to your domain and check do you use http or https. Its worked for me. When I enter address with index.php its redirecting to domain.

| improve this answer | |
  • Updated , becuase was issue with different pages, now is fine. – BartZalas Jul 5 '18 at 10:24
  • yes working thankyou – Raghu Jul 5 '18 at 12:47

First, you have to make sure that Apache rewrites module is enabled on your server and then follow the below steps...

  1. Login to Magento admin account and go to this path - System > Configuration > General > Web.

  2. Select the yes for Use Web Server Rewrites in Search Engine Optimization (on Web settings).

  3. Now, Go to Magento root directory and add following code in .htaccess.

<IfModule mod_rewrite.c>

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


| improve this answer | |

It require enable mod_rewrite module

Use web server rewrite "Yes" from admin setting

Check refrence from here : How to remove index.php from your Magento site URL

| improve this answer | |
  • thanks...it is there but when we enter manually index.php it should not show – Raghu Jul 5 '18 at 9:37

Try this :

remove index.php change in below path Override file in local and _updatePathUseRewrites comment line 599 and 606

| improve this answer | |
  • tried this now but same issue – Raghu Jul 5 '18 at 9:57

You can manage it through .htaccess file of your magento root directory. Add the following code to your .htaccess it should work.

RewriteEngine On
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.your-domain-name.com/$1 [R=301,L]
| improve this answer | |
  • thanks this is not working and I have the path for magento /var/www/html/testfolder/ – Raghu Jul 5 '18 at 10:13
  • Check the updated answer. – Sukumar Gorai Jul 5 '18 at 10:29

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.