【CentOS 7架構14】,訪問控制FilesMatch#

shallow丿ovephp


訪問控制FilesMatch

  • 核心配置文件內容 <Directory /data/wwwroot/111.com> <FilesMatch "admin.php(.*)"> Order deny,allow Deny from all Allow from 127.0.0.1 </FilesMatch> </Directory>

能夠用於匹配目錄名與連接html

[root@localhost ~]# vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
     37 #       AllowOverride AuthConfig
     38 #       AuthName "111.com user auth"
     39 #       AuthType Basic
     40 #       AuthUserFile /data/.htpasswd
     41 #       require valid-user
     42 #    </FilesMatch>
     43 #    </Directory>
     44     <Directory /data/wwwroot/111.com>
     45         <FilesMatch user.php(.*)>
     46         Order deny,allow
     47         Deny from allow
     48         Allow from 127.0.0.1
     49         </FilesMatch>
     50     </Directory>
     51     
     52     <Directory /data/wwwwroot/111.com>
[root@localhost ~]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@localhost ~]# /usr/local/apache2.4/bin/apachectl graceful
[root@localhost ~]# curl -x 192.168.9.134:80 http://111.com/admin/111 -I
HTTP/1.1 404 Not Found
Date: Sun, 05 Nov 2017 08:37:49 GMT
Server: Apache/2.4.29 (Unix) PHP/5.6.30
Content-Type: text/html; charset=iso-8859-1
[root@localhost ~]# curl -x 192.168.9.134:80 'http://111.com/user.php?111' -I
HTTP/1.1 200 OK
Date: Sun, 05 Nov 2017 08:38:41 GMT
Server: Apache/2.4.29 (Unix) PHP/5.6.30
X-Powered-By: PHP/5.6.30
Content-Type: text/html; charset=UTF-8

[root@localhost ~]# curl -x 127.0.0.1:80 'http://111.com/user.php?111' -I
HTTP/1.1 200 OK
Date: Sun, 05 Nov 2017 08:39:19 GMT
Server: Apache/2.4.29 (Unix) PHP/5.6.30
X-Powered-By: PHP/5.6.30
Content-Type: text/html; charset=UTF-8
相關文章
相關標籤/搜索