Pay attention to the version of apache.
****************************************
apeche2.2
1. Want to block access from a certain website or IP,
Order Allow,Deny
Allow from all
Deny from domain.org #Prohibit domain.org from accessing this server
2. Only allow a certain website or IP to access the server
Order Allow,Deny
Allow from ip1 #Only allow the specified IP to access the server
3. Allow all IP access
Order Allow, Deny
Allow from all #Only allow all IPs to access the server
******************************************
Please check your apache version, 2.2 and 2.4 have different permission configuration.
2.2 as follows:
Options Indexes FollowSymLinks
AllowOverride All
Allow from all
Order allow,deny
2.4 as follows:
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
<Directory "Website Directory">
Options Indexes FollowSymlinks #
AllowOverride All
Require all granted
</Directory>
****************************************
turn someone else's
After Apache was upgraded from 2.2 to Apache2.4.x, the setting method of the configuration file httpd.conf has changed greatly. In the past, deny from all was changed to Allow from all to achieve external network access. Now it is Require all denied and Require local All should be Require all granted.
.htaccess If it doesn't work, just remove the comment (#) in front of LoadModule rewrite_module modules/mod_rewrite.so.
Let's take a look at the changes of Apache2.4: ( official English description )
All requests are denied
Configuration on 2.2
Order deny,allow
Deny from all
Configuration on 2.4
Require all denied
All requests are allowed
Configuration on 2.2
Order allow,deny
Allow from all
Configuration on 2.4
Require all granted
All hosts in the domain can access example, all other external hosts are denied access
Configuration on 2.2
Order Deny,Allow
Deny from all
Allow from example.org
Configuration on 2.4
Require host example.org
For external network access, set Require local to Require all granted.
1
2
3
4
5
6
|
经常会用到的:
Require all denied
Require all granted
Require host xxx.com
Require ip 192.168.1 192.168.2
Require local
|
Require all denied
Require all granted
Require host xxx.com
Require ip 192.168.1 192.168.2
Require local
for example
仅允许IP:192.168.0.1 访问
Require all granted
Require ip 192.168.0.1
仅禁止IP:192.168.0.1访问
Require all granted
Require not ip 192.168.0.1
允许所有访问
Require all granted
拒绝所有访问
Require all denied
默认是 Require local 仅允许本地访问。