Rule to redirect non logged in User to Custom Registration/login Page in .htaccess file

I am trying to redirect not logged in users from the "/purchaseads/purchase.php" to custom registration/login url "/purchaseads/registrationurl"on wordpress website. Unfortunately when visit the url "/purchaseads/purchase.php" even as a non logged on user nothing changes, doesn’t redirect to custom register/login form.

Force redirect not logged in user to (wp-login.php or wp-admin) for specific page

I am currently using a WordPress plugin (Pagerestrict plugin which references URLS based on Page ID/Slugs)to restrict certain pages to logged in users only. This plugin works fine with standard wordpress URL structure but the issue I have is some of my pages which are directly linked to some plugin functionality have http://mywebsite.com/wp-content/plugins/purchase.php instead of a standard http://mywebsite.com/wp-content/plugins/purchase/ wordpress url structure. So what i tried in cases like this is to manually add the functionality below which didn’t work