I have site A on Wordpress and site B on PHP. How can I achieve that if a user tries to enter my site B without being logged in to my site A, he is redirected to the login page of my site A.
I have searched for information on how to redirect from a form to an external page, but I have not found what I need, because in my case if you wanted to access site B directly from the URL, you should automatically be redirected to site A.
You can make a redirect from .htaccess taking as example code:
Or if you prefer you can do a redirect from a small PHP script either in your index.php of site A like the following:
Or you also have redirection from CPanel if you have CPanel.