How to remove index.php from url in magento?

Magento uses the Front Controller pattern, all of its page request go through a single entry point index.php. If you prefer to hide the “index.php” part in the URLs you need to enable web server rewrites in Magento admin.

A URL like “http://www.testmagento.com/electronics/cell-phones.html” is much more user friendly than “http://www.testmagento.com/index.php/electronics/cell-phones.html”, it also hides the fact that the page displayed is a PHP page so hiding “index.php” in URLs is good for security purpose. Hiding “index.php” does not affect website performance in any way neither it affects search engine rankings.

Here are the  steps to enable web server rewrites from Magento admin:

1. Login to Magento admin
2. Go to Admin >> System >> Configuration
3. Under “General tab”, click on “Web” section
4. Expand “Search Engines Optimization”
5. Select “Yes” in dropdown for “Use Web Server Rewrites”
6. Save the configuation
7. Clear the Magento Caches.

Web Server Rewrite

Assuming your are running Apache web sever, you need have “mod_rewrite” apache module enabled and you need to create a .htaccess file in the {{Magento_Root}} folder before enable web server rewrites from Magento admin.

Open/Create .htaccess file in  {{Magento_Root}} folder and add the following entries:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Now refresh your home page, index.php should be removed from all URLs.

Comments

Leave a Comment

Back to top