Mladen Mijatovic
Mladen Mijatovic

Reputation: 11

How to remove index.php from middle of URL

I am using .htaccess redirection rule for removing index.php from URL and it works good when I try to access mysite.com/index.php redirecting me on mysite.com. Redirection rule I use in .htaccess is exactly:

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

But when I try to access URL for ex. mysite.com/index.php/folder/folder1 it still works. It not removing index.php from middle of URL. And my Google webmaster tool showing me duplicate descriptions/keywords for mysite.com/folder and mysite.com/index.php/folder and both links still works.

Any htacces rule to remove index.php from middle of URL and redirect to URL without it?

Using Joomla 2.5.11. btw.

Appriciate any help.

Upvotes: 0

Views: 2666

Answers (2)

Jigar Patel
Jigar Patel

Reputation: 211

First rename htaccess.txt to .htaccess.

then goto global configration and set Use URL rewriting - Yes

then save & check

may this one very help !

Upvotes: 0

Mike Rockétt
Mike Rockétt

Reputation: 9007

RewriteRule ^index\.php / [R=301,L]
RewriteRule ^index\.php\/(.+) /$1 [R=301,L]
RewriteRule ^(.+)\/index\.php\/(.+) /$1/$2 [R=301,L]

You have to check the end of a string, not the beginning. Also, in case you have index.php in a sub folder, the third rule will take care of that (provided you have the necessary silent rules for them).

Note: only use R=301 if it works for you. Otherwise, for testing, just use R.

Upvotes: 2

Related Questions