Redirect index.php to root in .htaccess
.htaccess, magento, magento-1.7, mod-rewrite, url-rewriting
Solution
You can capture the part after `index.php` and redirect the client with
RewriteEngine on
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]
This redirects all requests starting with `index.php/` to the URL without `index.php`. Additionally `index.php` and `index.php/` are redirected to the home page.
Update:
To exclude the admin area, you must insert an additional `RewriteCond` before the first rule
RewriteCond %{REQUEST_URI} !/admin/
All together gives
RewriteEngine on
RewriteCond %{REQUEST_URI} !/admin/
RewriteRule ^index\.php/(.+)$ /$1 [R,L]
RewriteRule ^index\.php/?$ / [R,L]
Problem
I installed Magento on my shared hosting server. I have made all the necessary changes in magento admin panel. All the url's work fine. But the only problem is I can access my products on the store using: http://mydomain.com/category/product.html and also with http://mydomain.com/index.php/category/product.html So I want to know how I can get rid of index.php. I want to redirect the url which consists of index.php to the url without index.php Before posting here I checked the magento forums and also searched on stackoverflow but found no success.