M
M
mr_blond972015-07-29 22:53:36
linux
mr_blond97, 2015-07-29 22:53:36

How to restrict access to the virtual path for all IPs except one in .htaccess?

In order to restrict access to the directory for all IPs except one, you need to put .htaccess into it with the following content:

Order Deny,Allow
Deny from all
Allow from 1.1.1.1

You can do it this way in virtual hosts
<Directory "/var/www/html/mysite/my_folder">
Order Deny,Allow
Deny from all
Allow from 1.1.1.1
</Directory>

But how to solve this problem if there is no my_folder directory and it is a virtual path?
Below is the content of the .htaccess directory mysite
/var/www/html/mysite/.htaccess :
AddDefaultCharset utf-8
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteRule ^favicon.ico$ - [F,L]
# если директория или файл существуют, использовать их напрямую
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# иначе отправлять запрос на файл index.php
#RewriteRule . index.php <-- было
RewriteRule ^([^/].*)$ /index.php/$1 [L] # <-- стало

I changed the question quite a bit, removed the mention of ssh and added "virtual paths" and .htaccess with +FollowSymLinks. I did not see the point in creating another topic that would almost completely duplicate the previous one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2015-07-30
@mr_blond97

.htaccess is the control file of the apache web server
and scp works over the ssh protocol, not related to the web server at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question