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.
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]
If you want to drop index.php from ALL links on your site, this solution actually worked the best for me:
RedirectMatch 301 /index.php/(.*) http://www.yourdomain.com/$1
Source: http://www.lionseo.com/blog/htaccess-redirect-301/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With