.htaccess allow certain ip with file exceptions for all others - apache

I know it's a bit of a beginner question but tried several combinations and none work... here's what i need to achieve using .htaccess and .htpasswd
I have a www.mysite.com/protected folder.
By default, all ip's shouldn't see this folder and any other files inside it exists (basically they should be redirected to www.mysite.com)
A certain IP (my external IP M.M.M.M) should be able to access that protected folder and be requested a username and password
All ip's should be able to see some files inside the folder without being asked for password (www.mysite.com/protected/file1 and www.mysite.com/protected/file2)
I know the latter rule opens an exception on the first but that's how i need it (a general rule denying all and then whitelisting some files)
Thanks in advance for any help, been struggling with this for a bit now :(

Related

Make server directory inaccessible to all external connections

I'm creating a very simple login system where my php code stores and reads file names(account name) and content(password) but anyone could simply just navigate to that folder and read whatever. so what i want is that a folder gets "locked" from any connections, and still read / write to it with php. i use xampp to host, if it has any relevance
is this possible? if not, are there other simple ways of storing / reading account password and name?
found my solution, by putting
order deny,allow
deny from all
inside .htaccess in the folder i want private

Password Protecting directory using Apache and windows authentication? NOT .htaccess

For part of my assignment, I had to create two local directories in my Apache htdocs path and password protect them so that only one user can access them. I did this using htaccess. However, this was apparently the wrong answer because they wanted authentication using windows user login user/pwd.
I don't understand how i can do this. How can i create a folder that is only accessible by the user with the same name?
Thanks for any advice. I do not need a solution, just some information on where to start looking. Everything I find seems to require htaccess. Unless i am thinking of this wrong and there is a module i can use with htaccess to make this work.
Thanks for the help.
I am not sure what your prof is looking for but you can probably do this by working with the windows folder sharing and permission options
Setting folder Share permissions

where is .htaccess in parallel plesk? should I creat it by myself?

I can't find .htaccess in my root and my host provider is not in touch, either I can't change my host and disable my site, because it's about an reward registration.
now I don't know how could I have .htaccess?
for describtion, I want to active gzip for my site...
I researched in some places and didn't find any useful answer for me...
Actualy there should be a file with name .htaccess on your server's root folder, sometimes it may be empty and you have to write your commands on it! but if there is not, and if your host gave you privilege, you can creat one...

retrieve a file list knowing the htaccess user and password

There's and IP camera problem here. I know the htaccess username and password. How can I retirieve a filelist from that camera. I'm not sure if this is a hacking question, because I know the username and the password, but if it is, please to be deleted.
Thanks in advance!
Because you are mentioning the .htaccess file, I'm assuming you are using the http protocol, on which you can't get lists of files, only if the webserver serves them (meaning, "Options +Indexes" is set). If the server serves the file lists, you could get the list with something like:
wget http://username:password#example.com/path/to/directory/
You'd have to replace wget with the program of your choice.

How do I hide my Scripts folder?

I have a directory on my website specifically for javascript files, I want these javascript files to be hidden, so if I type the url to it it says Forbidden or disallows access, but my front-end website files can still access them to execute them when needed. Is there a way to do this through a FTP client?
Cheers,
Dan
You can't do this trough a ftp client. It is the task of your webserver to forbid access to certain files.
If you change permission, the webserver won't have access to them anymore, so this is not the way to go.
You must configure your webserver to restrict the access. If you're using Apache, you can use an .htaccess file. There's different ways of doing this, many depends on the way the webserver is configured.
The easiest is to put an .htaccess file in your Scripts folder which contain only this none line :
deny from all
However, like peeter said, there's a good chance this will break your site, since the browser must access theses files, so you can't restrict access.
Put a htaccess file in your scripts folder containing deny from all, but this will stop your pages from accessing the scripts also (though not if you pass them through the PHP engine first)
You're trying to hide JavaScript files that are executed on the clients side. If a client(browser) cannot access the files means non of your javascript code is executed.
If I understood your question correctly then you cannot achieve what you're trying to achieve.