cPanel hosted sites return Error 404 when using .htaccess basic auth with Apache

If you have a website hosted on a cPanel server, and try to setup Basic Auth in a sub-folder of your site, you might be dismayed to see that instead of the Basic Auth login form, you see an Error 404 page. 

If you are hosting a site like Wordpress/Craft/EE/Laravel etc, that uses a rewrite in the .htaccess file:

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

The fix is to add a slash after the dot (.) in the last line. Changing:

RewriteRule . /index.php [L]


RewriteRule ./ /index.php [L]

Thanks to Cartika for finding the answer to this!

Note: If you are using WordPress, and regen your permalinks, this fix will be removed from the root .htaccess file, as Wordpress will rewrite it without the added slash.