Demonic Posted December 16, 2006 Share Posted December 16, 2006 Is there a way to make files able to not be accessed directly?Like can be accessed other ways but when viewing files straight threw the domain path it gives an error :). Link to comment https://forums.phpfreaks.com/topic/30902-making-some-files-access-denied-if-there-accessed-directly/ Share on other sites More sharing options...
drifter Posted December 16, 2006 Share Posted December 16, 2006 I believe you are looking for .htaccess and "hot linking" - you can google that.if this is not what you are looking for, you may be looking for something related to permissins which you need to talk to your hosting company to see how your server is set up - probably not the best.The last option is to store the files our site of the web root. Link to comment https://forums.phpfreaks.com/topic/30902-making-some-files-access-denied-if-there-accessed-directly/#findComment-142577 Share on other sites More sharing options...
Demonic Posted December 16, 2006 Author Share Posted December 16, 2006 I know theres .htaccess ways of doing it but i need the PHP coding way :'(. Link to comment https://forums.phpfreaks.com/topic/30902-making-some-files-access-denied-if-there-accessed-directly/#findComment-142585 Share on other sites More sharing options...
trq Posted December 16, 2006 Share Posted December 16, 2006 There are ways but it really depends how your doing things. For instance, in every page of my applications I firstly invoke my config.inc.php file. Within this file I define the constant HASCONFIG to true. Then, in any other included file (say db.lib.php) I check for this constant. eg;[code=php:0]if (!HASCONFIG) { echo "This file is unable to be called directly"; exit();}[/code]This meens that trying to browse to db.lib.php will get you the above error. However, in my pages I can use it as long as I include it after my config.inc.php. eg;index.php[code=php:0]<?php require_once "config.inc.php"; require_once "db.lib.php"; // rest of code.?>[/code] Link to comment https://forums.phpfreaks.com/topic/30902-making-some-files-access-denied-if-there-accessed-directly/#findComment-142604 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.