Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess deny from all doesn't work

my problem is that I want to deny the access to a folder but I can't. I've put a .htaccess file in this folder with just these lines:

order deny,allow
deny from all

Any idea of what can be happening?

like image 813
Manolo Avatar asked Aug 10 '13 12:08

Manolo


People also ask

What does htaccess Deny from all do?

htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.

How do I deny access to my site with an .htaccess file?

htaccess IP deny access. To deny access to a block of IP addresses, simply omit the last octet from the IP address: deny from 123.456. 789.

What permissions should .htaccess have?

What permissions should the file have? 644 permissions are usually fine for an . htaccess file. When you create the file on the server, it should already have these permissions set, so there is most likely nothing to change.

How do I restrict IP address in htaccess?

In this tutorial, you've learned the easy way to block or allow visitors from specific countries. All you need to do is generate the country's IP address via Country IP Blocks, then insert an access control list (ACL) into your . htaccess file. We hope that this guide was helpful.


2 Answers

I get it! It was due to the apache configuration. In my foo.conf of sites-avaiables directory I had:

AllowOverride None

As apache doc says, AllowOverride Description: Types of directives that are allowed in .htaccess files

When it is changed to:

AllowOverride All

it works perfectly! You can also configure it with specific options:

AllowOverride directive-type

directive-options at: apache.org

like image 128
Manolo Avatar answered Nov 02 '22 23:11

Manolo


I had the same issue using that method. Try this instead:

RewriteEngine On
RewriteCond %{REQUEST_URI} foldername
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.44$
RewriteRule . - [R=404,L]

With this method you need to add your own ip.

Options: instead of the last line being a 404 page not found:

RewriteRule . - [R=404,L]

you can change it to a 403 forbidden:

RewriteRule .*? - [F]

or redirect to your homepage:

RewriteRule . http://www.domain.com/ [R,L]
like image 29
cknz Avatar answered Nov 03 '22 00:11

cknz