How to redirect index.php for SEO

  • 13th January 2020
  • HTACCESS, SEO
  • 0 Comments
  • Christophe

If your homepage is being treated by Google as two separate pages – e.g. site.com/ and site.com/index.php – you may be experiencing search engine indexing issues too. Unless the index file is redirected to the root, your homepage may be being treated as two different pages but with duplicate content which can cause a whole host of indexing problems. This is, however, quite an easy and quick problem to fix.

Before you start, make sure that mod_rewrite is enabled with PHP and that your using PHP version 5.2.6 or higher.

Note that this fill will remove all instances of ‘index.php’ in all your page URLs so make sure that this isn’t going to cause problems before you do it.

Also, this fix requires a good working knowledge of HTACESS as mistakes can be very serious so please don’t attempt this unless you know what you’re doing!

Here’s the code you’ll need:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]

Here are the steps to add it:

  1. Open your HTACESS file in preparation for editing it. There are several ways to do this including via FTP. However, don’t forget to back it up first!
  2. Once your HTACCESS file is open and ready for editing, add the code (above)
  3. Finally, save the changes to the HTACCESS file and test that it’s working.

Need help? Give us a call on 0114 383 0711

Christophe