Htaccess disallow inside directory - .htaccess

i have a directory with .htaccess with deny
deny from all
and inside that directory there is another directory with .htaccess like this:
<Directory "/dir1/dir2">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
How can i deny the access to second directory with htaccess on first directory?
Thanks for answers.

<Files *>
deny from all
</Files>
did the job :)

Related

.htaccess How allow directory

folders on server
/test
/test1
/test2
.htaccess
Order Deny,Allow
Deny from all
Allow from **.***.***.**
<Directory /test>
Options +Indexes
Allow from all
</Directory>
We are use .htaccess but adress http://test.com/test/ not work. Tell me please where errror ?

Can I specify a wildcard or regex as a Directory in htaccess?

We have many, many sites, all of which contain a "customer/uploadsfolder". We have to allow uploading, but want to block any GIF files, as well as turn off PHP in the folder as shown below. The question is, do we need one entry for every folder, or can wildcards/regex be used?
<VirtualHost *:80>
<Directory /customer/uploadsfolder>
deny from all
<Files ~ "^\w+\.(gif)$">
order deny,allow
allow from all
</Files>
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
</Directory>
</VirtualHost>
Yes, use LocationMatch (or "Location ~").
<LocationMatch "\/customer\/uploadsfolder\/.*\.(php|gif)">
order allow,deny
deny from all
</LocationMatch>

htaccess directory listing

I'm trying to list files in one particular directory and with one particular ip. This htaccess file is located in that directory. So far, it seems that the hosting does not allow me to list directories. On localhost i can list everything in that directory, except the IndexIgnore ones, of course. The htaccess file content is:
Options +Indexes
<Limit GET POST>
order deny,allow
deny from all
allow from 1.1.1.1
</Limit>
IndexIgnore tabele_remote.php
IndexIgnore demo.txt
IndexIgnore functions.php
IndexIgnore config.php
It seems that AllowOverride directive is set somewhere previously
Also check there is no IndexIgnore * set on the parent directories or server entirely
change order deny,allow to order allow,deny and give it a try.
Also set AllowOverride all

Deny access to all files except index file - Apache2

I'm configuring an Apache2 server, but I'm having trouble figuring out how to deny access to all files/directories except the index file.
My website resides inside /var/www/
This is my current setup in the /etc/apache2/apache2.conf file:
<Directory />
Order Deny,Allow
Deny from all
Options None
AllowOverride None
</Directory>
<Directory /var/www/>
Order Allow,Deny
Allow from all
</Directory>
How do I solve my problem? Thanks!
Try adding a <FilesMatch> for index.php. If it doesn't work in this position, move it above the directory's Deny from all. Change index.html to whatever your index file is.
<Directory />
Order Deny,Allow
Deny from all
Options None
AllowOverride None
</Directory>
<Directory /var/www/>
# Deny first, then allow
Order deny,allow
# Deny everyone from everything
Deny from all
<FilesMatch index\.html>
# but allow index.html
Allow from all
</FilesMatch>
</Directory>
I think you're better off simply piping everything to the index file, not denying access to everything else.
This can be done through RewriteRule:
RewriteEngine On
# index goes to index (this is first to prevent infinite loop)
RewriteRule ^/index\.html$ - [L]
# everything else goes to index
RewriteRule .* /index.html [L]

Allow directory listing only for a IP

I've activated directory listing with this line in the .htaccess:
Options +Indexes
How can I limit this to only one IP address with having access to all files/directories for everyone (every IP)?
Not tested:
allow from all
Options -Indexes
<Files *>
deny from all
allow from 195.112.15.4
Options +Indexes
</Files>
This way the Options +Indexes will be valid only for IP 195.112.15.4
I know this is an old thread but as I have just found something that seems to work, I've decided to share it here.
Adding this seems to do the trick:
<Files .>
Order Deny,Allow
Deny From All
Allow From 195.112.15.4
</Files>
This is what I got working for me, this is the .htaccess inside the folder I don't want everyone to be able to list, but if I give them a link to a file inside it, I want anyone (all) to be able to download the link.
allow from all
Options -Indexes
<Files *>
deny from all
allow from all
Options -Indexes
</Files>
<Files .>
Order Deny,Allow
Deny From All
Allow From xx.xx.xx.xx
# put the IP you want to allow indexing for above here
Options +Indexes
</Files>
tested
supposing "index.html" is the one configured as your DirectoryIndex, and XX.XX.XX.XX is your IP address, simple put these lines:
<FilesMatch "index.html">
Order deny,allow
Deny from all
allow from XX.XX.XX.XX
</FilesMatch>

Resources