File permissions

Problems with the Windows version of XAMPP, questions, comments, and anything related.

File permissions

Postby anonimouse » 12. November 2009 22:35

Can anyone tell me how do I protect a file from being accessed by users? I'm using apache in windows vista and I have a folder that is the way I want. When the user browses to this folder he gets the error 403 - Forbiden. Now I have another folder and I want to pretect this folder too. I've checked all the permissions in the folders propreties at the security tab and they are the same. I've tried chmod php function but it doesnt work. I'm very confused because I search the web and I found that cdmod is not available on windows but I had somehow changed the permissions on one folder and I'm not able to do it on other.

What I want is to this:

Image

To happen in other folder.

Can anyone give me a hand?

thanks!
anonimouse
 
Posts: 4
Joined: 12. November 2009 22:24

Re: File permissions

Postby Altrea » 12. November 2009 23:54

.htaccess?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: File permissions

Postby anonimouse » 13. November 2009 02:05

I checked .htaccess and there nothing there that i've changed. I want to restric access to a folder so when someone tries to access to this folder or any file on the folder gets the 403 error.
anonimouse
 
Posts: 4
Joined: 12. November 2009 22:24

Re: File permissions

Postby anonimouse » 13. November 2009 02:27

I know is possible to do this, and I have did it to the folder "include" that I show on the picture. I've try to make simple php file with:

<?php
if(chmod('./php/ajax.php', 0400)) {
echo 'true';
} else {
echo 'false';
}
?>

When I run this file I get 'true' but the access to the file is not forbiden...
anonimouse
 
Posts: 4
Joined: 12. November 2009 22:24

Re: File permissions

Postby Izzy » 13. November 2009 02:51

Now I have another folder and I want to pretect this folder too...

...I want to restric access to a folder so when someone tries to access to this folder or any file on the folder gets the 403 error.

(if(chmod) BTW, there is no chmod in Windows, this is used in Linux only.

Here's more on .htaccess to do this job you want done.

Create a .htaccess file in your text editor and add this line at the top:
Deny from all
Then save the .htaccess file in the folder you want to protect with a 403 Access denied! error message.
(You may have save file problems in Vista, so open Notepad by right clicking on the notepad.exe file and select to run as an administrator. Then under the File menu in your Notepad you can select Save as .htaccess).

If you want to deny access from all but allow access to some, then you could add lines like these:
Order deny,allow
Deny from all
Allow from 127.0.0.1


The above will allow access to localhost (or 127.0.0.1) which is the PC that XAMPP is installed on, which in turn will allow you as the developer of your pages on your XAMPP to access the folder as normal but denies access to everyone else giving them a 403 Access denied! error message.

If you wish, you can add others that you want to have access by adding their IP, if you know it, to the entry like so:
Order deny,allow
Deny from all
Allow from 127.0.0.1 192.168.0.2
Allow from 188.40.45.85
Allow from myfriendsdomain.com


It is also possible to add partial IP address in the form Allow from 192.168. which will allow all on the 192.168.0.0 LAN with IPs starting 192.168. to access.

The .htaccess is very powerful and quite flexible in this regard and a web search for .htaccess will give many more helpful examples in the search results - this site for example:
http://www.evolt.org/ultimate_htaccess_examples
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: File permissions

Postby anonimouse » 13. November 2009 17:00

Thank you very very very much my friend!
anonimouse
 
Posts: 4
Joined: 12. November 2009 22:24


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 135 guests