How to redirect index.php for SEO

A homepage may be accessible both at the site root and at /index.php. If both addresses serve the same page, decide which is the intended canonical destination before adding a redirect.

Check the actual behaviour

Request each URL and record its status, destination and canonical output. Some installations already redirect correctly. Others use index.php as part of their working permalink structure, so removing it everywhere can break genuine pages.

Use a rule scoped to the real duplicate

For an exact homepage duplicate, the intended change is a permanent redirect from that exact old path to the root. The correct configuration depends on Apache, Nginx, the hosting panel and existing rules. Ask the host which site-level mechanism applies; do not paste a broad rule into shared server configuration.

Test before and after

Back up the existing settings. Test the root, the duplicate path, representative posts, query strings and the admin area. The duplicate should reach the correct public destination in one hop, without a loop. Do not redirect every missing URL to the homepage.

The previous snippet removed index.php from more paths than the homepage. It has been removed to avoid treating different server and permalink configurations as interchangeable. See our technical SEO service for a scoped review.

Sources and further reading

Guidance checked 26 October 2026: Google’s redirect guidance.

Illustrations