Apache redirect /index.php to /

Redirect index.php to /

Most websites that are running PHP use an index.php. Apache servers are also directed to look for an index.php when an address ends with a slash /. For example:

/* these two addresses will run the same file */ http://www.marcwatts.com.au/index.php http://www.marcwatts.com.au

This causes a couple of problems.

The first problem is our address may contain index.php. This doesn't look as nice and really isn't needed.

The second problem is we now have two addresses for the one page. If we were tracking page impressions our scripts would need to understand that both addresses redirect to the same page and to count them together.

Overall its better to redirect /index.php to /. Here is an htaccess solution to solve our problem.

### redirect /index.php to / ### RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ RewriteRule ^index\.php$ http://www.marcwatts.com.au/ [R=301,L]

Just replace the domain above with your own and the index.php address will be replaced.