Reputation: 971
If I have a URL called: www.example.com
and I have an application in the next URL: www.example.com/app/
, how can I forbid access to www.example.com
but not to the app?
Any simple way?
Thanks.
Upvotes: 0
Views: 92
Reputation: 82814
If you need to do this from within PHP, you can simply set the correct HTTP status and exit the program:
if ($_SERVER['PATH_INFO'] === '/') {
header('', false, 403);
die('Access forbidden.');
}
See the header() docs and the description of HTTP return codes.
But in the general case, @CooPer and the others are right, the server config is a better location to handle that globally.
Upvotes: 1
Reputation: 3516
use .htaccess
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
<Directory /app>
Order Allow,Deny
Allow from all
</Directory>
Upvotes: 2