thefollower Posted December 23, 2007 Share Posted December 23, 2007 Hey. Was wondering how i stop users accessing my root directory on local host.. i don't want them being able to find my connect script... or is it automatically secured on local host ? I use xampp/apache package Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 23, 2007 Share Posted December 23, 2007 As long as your file ends in a .php extension so that it will be parsed if someone browses to it, no one can see the code or data in the file (unless they have direct access to the file through FTP or direct access to your computer.) Give it a try, browse to your file and see what you get. Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421770 Share on other sites More sharing options...
thefollower Posted December 23, 2007 Author Share Posted December 23, 2007 But say all my files are in a folder: grwgwqd < folder name So they then went: Www.sitename.com/grwgwgd then they can see all my site's files? Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421781 Share on other sites More sharing options...
wildteen88 Posted December 23, 2007 Share Posted December 23, 2007 Well you could place a .htaccess file in that folder to deny access, or just simply place an blank index.html file in that folder so when a user goes directly to Www.sitename.com/grwgwgd all they'll get is a blank page, or if you go the .htaccess route a 403 Forbidden error. Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421783 Share on other sites More sharing options...
drummer101 Posted December 23, 2007 Share Posted December 23, 2007 Try what PFMaBiSmAd suggested. PHP is rendered server side, and anything between the <? and ?> brackets is NOT shown to the end user. Your first question and second are two completed different things. PFMaBiSmAd answered your first question correctly. Answer to your second question, create an .htaccess file. 1.) Open notepad 2.) copy and paste "Options -Indexes" 3.) save as .htaccess (make sure it's not saved with a .txt extension) 4.) move that file to your root (htdocs) folder 5.) open www.sitename.com/grwgwgd, you should get a 403 Access Forbidden error. Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421784 Share on other sites More sharing options...
thefollower Posted December 23, 2007 Author Share Posted December 23, 2007 so the .htaccess has: <?php Options - Indexes ?> And thats it ? Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421785 Share on other sites More sharing options...
wildteen88 Posted December 23, 2007 Share Posted December 23, 2007 No need for the php tags just the configuration code. Also the .htaccess has no filename eg: the following is incorrect: filename.htaccess it's just .htaccess When creating this file with Notepad, make sure the File Type pull down menu is set to All Files and not Text Document Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421790 Share on other sites More sharing options...
drummer101 Posted December 23, 2007 Share Posted December 23, 2007 Exactly what wildteen88 said. Kepp in mind though, if you put this .htaccess file in your root directory EVERY directory underneath it will be disallowed from giving a directory listing. ex. root | images \ members If you wanted to say, disallow directory display of all directories, except members, you'd make a .htaccess file with "Options +Indexes" and place it in the members. root & images would then be disallowed from showing the index, but members, and any subfolders contained within it, would show. In short, .htaccess files cascade down the directory structure. Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421802 Share on other sites More sharing options...
thefollower Posted December 23, 2007 Author Share Posted December 23, 2007 What are the reasons for allowing people to access the directory structure in the first place to me it just allows people to be one step closer to your files.. ? Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421824 Share on other sites More sharing options...
helraizer Posted December 23, 2007 Share Posted December 23, 2007 If you have an index page, whether it is .php, .pl, .cfm or whatever. the user will only be able to view that page. If they go to www.sitename.com/grwgwgd it will automatically take them to www.sitename.com/grwgwgd/index.[extension], so they can't see the files in that folder. Sam Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421832 Share on other sites More sharing options...
thefollower Posted December 23, 2007 Author Share Posted December 23, 2007 Ok i saved the file .htaccess.. How can i test this to see if it stops me ? I put the file in htdocs on my localhost so its not in a subfolder its in the main root of the whole site....what do i put in the url to see if it stops me? Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-421940 Share on other sites More sharing options...
juapo2 Posted December 24, 2007 Share Posted December 24, 2007 Now, go to www.sitename.com/grwgwgd/ and you should get the 404 Error. If you dont get anything, check you .htaccess file, it should have just Options -Indexes As you can see, if only has one space, then save the file with .htaccess and upload it, then go to www.sitename.com/grwgwgd/ it should work now Quote Link to comment https://forums.phpfreaks.com/topic/82929-permissions/#findComment-422099 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.