Kiwa
Kiwa

Reputation: 215

How to hide php from public?

I have .php file called mytasks.php which essentially does some background tasks. It is not meant to be opened by the public. Its just suppose to do its own thing, and if people keep opening it, it could be a serious issue for me (server overload).

So how can I make sure no one visits www.example.com/mytask.php. Is there a way I can block people from opening this URL?

Upvotes: 0

Views: 1804

Answers (2)

Dilyan Trayanov
Dilyan Trayanov

Reputation: 549

Basically when you are creating a website your application consists of two major directories.

  • /public (visible to the world)
  • /app (private business logic - not visible to the world)

I guess you have ftp access to the server and you should put your private PHP script outside the public directory.

Upvotes: 3

Ugur Eren
Ugur Eren

Reputation: 2204

You can block a file with apache/nginx
If you're using apache, add this to your .htaccess file:

<Files "mytasks.php">
        Order Deny,Allow
        Deny from all
</Files>

Or in nginx:

location ^~ /mytasks.php {
    return 404;
}

Upvotes: 2

Related Questions