// Redirect URLs containing index.php to non-index.php versions function redirect_index_php_urls() { if (strpos($_SERVER['REQUEST_URI'], '/index.php/') !== false) { $url_parts = explode('/index.php/', $_SERVER['REQUEST_URI']); if (count($url_parts) == 2) { $redirect_url = home_url() . '/' . $url_parts[1]; wp_redirect($redirect_url, 301); exit; } } } add_action('template_redirect', 'redirect_index_php_urls');