2

At my website, I was using URL addresses such as

http://me.example.com/index.php?p=home

Then I decided to use

http://me.example.com/?p=home

It all worked automatically without any ".htaccess" file. But addresses which contain "index.php" also still work. Some sites have links to my site in "old" format. I want people to stop using this "old" format and redirect them to the "new" format URL, whenever they use "old" format. All I want to do is to remove "index.php" from URL and also change this URL in visitor's browser.

Ivan Kuckir
  • 2,327
  • 3
  • 27
  • 46

1 Answers1

5

Here is the code that will go in .htaccess under DOCUMENT_ROOT:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php/?$ / [L,R=301,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643