switched the order of htaccess rules so that www. is removed before we try to remove index.php