1

When you need to deny access to folder for all IP you should to put .htaccess in this folder, which must contein:

Order Deny,Allow
Deny from all
Allow from 1.1.1.1

You can do it in virtual hosts like in this example:

<Directory "/var/www/html/mysite/my_folder">
Order Deny,Allow
Deny from all
Allow from 1.1.1.1
</Directory>

But how can i solve this task, when my_folder is not exist and its virtual directory?

There .htaccess, that situated inn "mysite" folder (/var/www/html/mysite/.htaccess) :

AddDefaultCharset utf-8
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteRule ^favicon.ico$ - [F,L]
# if directory exist, use it
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# if not, sent requests to index.php
#RewriteRule . index.php <-- before
RewriteRule ^([^/].*)$ /index.php/$1 [L] # <-- after

1 Answer 1

1

You should use <Location> instead of <Directory>.

<Location /my_folder/>
Order Deny,Allow
Deny from all
Allow from 1.1.1.1
</Location>

See document on sections for Apache 2.2, Apache 2.4.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .