How to block access to a page from the url

Asked

Viewed 1,303 times

2

I need to block the access of a Php page directly accessed by the url

  • Closed being duplicate mds... https://answall.com/questions/207034/block-p%C3%A1ginas-via-url/207047#207047

1 answer

3


With this code you prevent direct access:

if (strcmp(basename($_SERVER['SCRIPT_NAME']), basename(__FILE__)) === 0) {
    header("location: index.php");
}
  • I wanted to understand the little head of colleagues... The author of the question marked the answer as the best. Even so, there are always those who "didn’t like it" and those who don’t like it. My dear, if the answer is wrong, put in the right answer, say it. Present better solution. Should have. This is a script that helps. Surely there is more robust solution. But negative without giving feedback is a lot of bullshit.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.