The requested URL /index.php Was Not Found on this Server

Recently on a WordPress site had the error:

The requested URL /index.php was not found on this server.

The site had been moved to another location, different URL and within a sub-directory for testing. See the article Change WordPress Database Site URL References for moving a WordPress website.

The error was corrected by editing the .htaccess file. This was expecting the index.php file to be located at the root of the website URL, not one directory down.

.htaccess looked like:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

It was changed to:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^subdir/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdir/index.php [L]
</IfModule>

Where subdir is the sub-directory containing the WordPress site.