How can direct access to certain pages be blocked without modifying .htaccess?
Is there a way to achieve that with some code inside each script?
Any help will be much appreciated.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try adding this code at first line:
Following Michael Berkowski suggestion, an improved version of the answer would be like this:
UPDATE:
This code can be used to protect files with functions, classes, etc., used by other code, which don’t need to be accessed through the browser. Such as most WP plugins, admin and include files, wp-config.php, functions.php; files to fetch data transferred via POST method (Not GET), etc.