How to change redirection route to a php page for making it only accessible by logged-in members?

You can’t “redirect” to the external site in .htaccess – there is no way for your script to do the “MITM” bit to check their credentials.

Instead, you would need to internally rewrite the request to your PHP script (in .htaccess). Your PHP script then checks that the user is logged in, etc. as you are doing and then your PHP script issues the appropriate redirect – in the same way your script is currently redirecting back to your own site when authentication fails (although arguably that should be a 403 instead).

For example, before the WordPress front-controller:

RewriteEngine On

RewriteRule ^resources$ /php-authentication-script.php [L]

The above will internally rewrite any request for /resources to your /php-authentication-script.php. The URL in the browsers address bar remains as /resources, until your PHP script issues the redirect.