Giri
Giri

Reputation: 4909

htaccess permanent redirect index php to root

I'm using magento and all my urls contains index.php. Can anyone give me the code to remove index.php

My url looks like this

example.com/index.php/hi-how-are-you.html

I want it redirect to

example.com/hi-how-are-you.html

I want if anyone accessed the page using index.php it should redirect to non index.php url

Upvotes: 0

Views: 2579

Answers (1)

middus
middus

Reputation: 9121

This has been discussed time and again in the Magento forums, see e.g. this thread.


To redirect visitors from /index.php/path to /path you can use the following mod_rewrite Rule:

RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

To exclude the admin area, add the following condition before (!) the RewriteRule

RewriteCond %{REQUEST_URI} !^/index.php/admin/
RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

This tells mod_rewrite not (!) to rewrite if the request begins (^) with /index.php/admin

Upvotes: 3

Related Questions