十一週一次課

十一週一次課php

11.25配置防盜鏈css

11.26訪問控制Directoryhtml

11.27訪問控制FilesMatchlinux

11.25配置防盜鏈apache

• 經過限制referer來實現防盜鏈的功能vim

• 配置文件增長以下內容windows

  <Directory /data/wwwroot/www.123.com>瀏覽器

        SetEnvIfNoCase Referer "http://www.123.com" local_refcurl

        SetEnvIfNoCase Referer "http://123.com" local_refide

        SetEnvIfNoCase Referer "^$" local_ref

        <filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">

            Order Allow,Deny

            Allow from env=local_ref

        </filesmatch>

    </Directory>

• curl -e "http://www.aminglinux.com/123.html" 自定義referer

配置防盜鏈

防盜鏈,就是不讓別人盜用你網站上的資源,這個資源,一般指的是圖片、視頻、歌曲、文檔等。

referer的概念

你經過A網站的一個頁面http://a.com/a.html 裏面的連接去訪問B網站的一個頁面http://b.com/b.html ,那麼這個B網站頁面的referer就是http://a.com/a.html。 也就是說,一個referer其實就是一個網址。

1.配置防盜鏈

參考配置文件內容以下:

<Directory /data/wwwroot/111.com>
        SetEnvIfNoCase Referer "http://111.com" local_ref
        SetEnvIfNoCase Referer "http://111.com" local_ref
        SetEnvIfNoCase Referer "^$" local_ref
        <filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">
            Order Allow,Deny
            Allow from env=local_ref
        </filesmatch>
    </Directory>

[root@tianqi-01 ~]# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/111.com"
    ServerName 111.com
    ServerAlias www.example.com 2111.com.cn
   # <Directory /data/wwwroot/111.com>
   #<FilesMatch 123.php>
        #AllowOverride AuthConfig
        #AuthName "111.com user auth"
        #AuthType Basic
        #AuthUserFile /data/.htpasswd
        #require valid-user
    #</FilesMatch>

    </Directory>
    <Directory /data/wwwroot/111.com>
        SetEnvIfNoCase Referer "http://111.com" local_ref
        SetEnvIfNoCase Referer "http://aaa.com" local_ref
        #SetEnvIfNoCase Referer "^$" local_ref
        <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">
            Order Allow,Deny
            Allow from env=local_ref
        </FilesMatch>
    </Directory>

    SetEnvIf Request_URI ".*\.gif$" img
    SetEnvIf Request_URI ".*\.jpg$" img
    SetEnvIf Request_URI ".*\.png$" img
    SetEnvIf Request_URI ".*\.bmp$" img
    SetEnvIf Request_URI ".*\.swf$" img
    SetEnvIf Request_URI ".*\.js$" img
    SetEnvIf Request_URI ".*\.css$" img
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/111.com-access_%Y%m%d.log 86400" combined env=!img
</VirtualHost>

[root@tianqi-01 ~]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@tianqi-01 ~]# /usr/local/apache2.4/bin/apachectl graceful
[root@tianqi-01 ~]# 

2.測試網頁訪問:

//解釋說明:

首先定義容許訪問連接的referer,其中^$爲空referer,當直接在瀏覽器裏輸入圖片地址去訪問它時,它的referer就爲空。而後又使用filesmatch來定義須要保護的文件類型,訪問txt、doc、mp三、zip、rar、jpg、gif、png格式的文件,當訪問這樣的類型文件時就會被限制。

  • 在其它網站上連接這個網址,仍是打不開。

  • 而後在虛擬主機配置文件裏把第三方站點加入到白名單

在下面圖片上把第三方站點網址加入到白名單,而後保存退出從新加載配置。

[root@tianqi-01 ~]# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/111.com"
    ServerName 111.com
    ServerAlias www.example.com 2111.com.cn
   # <Directory /data/wwwroot/111.com>
   #<FilesMatch 123.php>
        #AllowOverride AuthConfig
        #AuthName "111.com user auth"
        #AuthType Basic
        #AuthUserFile /data/.htpasswd
        #require valid-user
    #</FilesMatch>

    </Directory>
    <Directory /data/wwwroot/111.com>
        SetEnvIfNoCase Referer "http://111.com" local_ref
        SetEnvIfNoCase Referer "http://ask.apelearn.com" local_ref
        #SetEnvIfNoCase Referer "^$" local_ref
        <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">
            Order Allow,Deny
            Allow from env=local_ref
        </FilesMatch>
    </Directory>
    SetEnvIf Request_URI ".*\.gif$" img
    SetEnvIf Request_URI ".*\.jpg$" img
    SetEnvIf Request_URI ".*\.png$" img
    SetEnvIf Request_URI ".*\.bmp$" img
    SetEnvIf Request_URI ".*\.swf$" img
    SetEnvIf Request_URI ".*\.js$" img
    SetEnvIf Request_URI ".*\.css$" img
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/111.com-access_%Y%m%d.log 86400" combined env=!img
</VirtualHost>

[root@tianqi-01 ~]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@tianqi-01 ~]# /usr/local/apache2.4/bin/apachectl graceful
[root@tianqi-01 ~]# 

在點擊連接http://111.com/eagle1.jpg 訪問就能夠了,這就是referer,以下圖

3.直接複製網址http://111.com/eagle1.jpg 在瀏覽器打開是顯示Forbidden的。若想要直接能訪問的話,須要把配置文件中的空referer的#去掉。

[root@tianqi-01 ~]# !vim
vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

   SetEnvIfNoCase Referer "^$" local_ref前的#去掉

測試語法錯誤並從新加載配置文件

[root@tianqi-01 ~]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@tianqi-01 ~]# /usr/local/apache2.4/bin/apachectl graceful
[root@tianqi-01 ~]# 

在瀏覽器中輸出網址http://111.com/eagle1.jpg ,是會直接顯示圖片的 

//這個就叫作空referer

4.使用curl進行測試

[root@tianqi-01 ~]# curl -x127.0.0.1:80 111.com/eagle1.jpg -I
HTTP/1.1 200 OK
Date: Sun, 04 Mar 2018 08:34:15 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Last-Modified: Sun, 04 Mar 2018 02:41:55 GMT
ETag: "7e3b-5668d270ae2c0"
Accept-Ranges: bytes
Content-Length: 32315
Content-Type: image/jpeg

[root@tianqi-01 ~]# 

也可使用-e來模擬referer,這個referer必定要以http://開頭,不然無論用。

[root@tianqi-01 ~]# curl -e "http://www.qq.com/123.txt" -x127.0.0.1:80 111.com/eagle1.jpg -I
HTTP/1.1 403 Forbidden
Date: Sun, 04 Mar 2018 08:37:20 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 ~]# 

[root@tianqi-01 ~]# curl -e "http://111.com/123.txt" -x127.0.0.1:80 111.com/eagle1.jpg -I
HTTP/1.1 200 OK
Date: Sun, 04 Mar 2018 08:38:02 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Last-Modified: Sun, 04 Mar 2018 02:41:55 GMT
ETag: "7e3b-5668d270ae2c0"
Accept-Ranges: bytes
Content-Length: 32315
Content-Type: image/jpeg

[root@tianqi-01 ~]# 

[root@tianqi-01 ~]# curl -e "http://www.qq.com/123.txt" -x127.0.0.1:80 111.com/eagle1.jpg1 -I
HTTP/1.1 403 Forbidden
Date: Sun, 04 Mar 2018 08:39:03 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 logs]# tail /usr/local/apache2.4/logs/111.com-access_20180304.log
127.0.0.1 - - [04/Mar/2018:12:10:46 +0800] "GET HTTP://111.com/123.php HTTP/1.1" 200 7 "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:12:14:43 +0800] "GET HTTP://111.com/123.php HTTP/1.1" 200 7 "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:12:17:23 +0800] "HEAD HTTP://111.com/123.png.png1 HTTP/1.1" 404 - "-" "curl/7.29.0"
192.168.11.1 - - [04/Mar/2018:12:24:36 +0800] "GET / HTTP/1.1" 200 7 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3343.4 Safari/537.36"
192.168.11.1 - - [04/Mar/2018:12:24:49 +0800] "GET /eagle1jpg HTTP/1.1" 404 207 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3343.4 Safari/537.36"
192.168.11.1 - - [04/Mar/2018:16:09:54 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "http://111.com/eagle1.jpg" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3343.4 Safari/537.36"
127.0.0.1 - - [04/Mar/2018:16:39:03 +0800] "HEAD HTTP://111.com/eagle1.jpg1 HTTP/1.1" 403 - "
http://www.qq.com/123.txt" "curl/7.29.0"        //這個就是它的referer
[root@tianqi-01 logs]# 

11.26訪問控制Directory

• 核心配置文件內容

  <Directory /data/wwwroot/www.123.com/admin/>

        Order deny,allow

        Deny from all

        Allow from 127.0.0.1

    </Directory>

• curl測試狀態碼爲403則被限制訪問了

訪問控制Directory

對於一些比較重要的網站內容,除了可使用用戶認證限制訪問以外,還能夠經過其餘一些方法作到限制,好比能夠限制IP,也能夠限制user_agent,限制IP指的是限制訪問網站的來源IP,而限制user_agent,一般用來限制惡意或者不正常的請求。

1.修改虛擬主機配置:

[root@tianqi-01 ~]# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/111.com"
    ServerName 111.com
    ServerAlias www.example.com 2111.com.cn
   # <Directory /data/wwwroot/111.com>
   #<FilesMatch 123.php>
        #AllowOverride AuthConfig
        #AuthName "111.com user auth"
        #AuthType Basic
        #AuthUserFile /data/.htpasswd
        #require valid-user
    #</FilesMatch>
    <Directory /data/wwwroot/111.com/admin/>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
    </Directory>

    <Directory /data/wwwroot/111.com>
        SetEnvIfNoCase Referer "http://111.com" local_ref
        SetEnvIfNoCase Referer "http://ask.apelearn.com" local_ref
        SetEnvIfNoCase Referer "^$" local_ref
        <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">
            Order Allow,Deny
            Allow from env=local_ref
        </FilesMatch>
    </Directory>
    SetEnvIf Request_URI ".*\.gif$" img
    SetEnvIf Request_URI ".*\.jpg$" img
    SetEnvIf Request_URI ".*\.png$" img
    SetEnvIf Request_URI ".*\.bmp$" img
    SetEnvIf Request_URI ".*\.swf$" img
    SetEnvIf Request_URI ".*\.js$" img
    SetEnvIf Request_URI ".*\.css$" img
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/111.com-access_%Y%m%d.log 86400" combined env=!img
</VirtualHost>
//解釋說明:

使用<Directory>來指定要限制訪問的目錄,order定義控制順序,哪一個在前面就先匹配哪一個規則(無論下面的規則先後順序),在本例中deny在前面,因此要先匹配Deny from all,這樣全部的來源IP都會被限制,而後匹配Allow from 127.0.0.1,這樣又容許了127.0.0.1這個IP。最終的效果是,只容許來源IP爲127.0.0.1的訪問。

檢測配置文件是否有語法錯誤,並從新加載配置文件

[root@tianqi-01 111.com]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@tianqi-01 111.com]# /usr/local/apache2.4/bin/apachectl graceful
[root@tianqi-01 111.com]#

[root@tianqi-01 ~]# cd /data/wwwroot/111.com/
[root@tianqi-01 111.com]# ls

123.php  eagle1.jpg  index.php
[root@tianqi-01 111.com]# mkdir /data/wwwroot/111.com/admin    //建立admin目錄,模擬網站後臺
[root@tianqi-01 111.com]# ls
123.php  admin  eagle1.jpg  index.php
[root@tianqi-01 111.com]# touch /data/wwwroot/111.com/admin/index.php//在後臺目錄下面建立文件
[root@tianqi-01 111.com]# ls admin/
index.php
[root@tianqi-01 111.com]# vim admin/index.php    //寫入內容
[root@tianqi-01 111.com]# cat !$
cat admin/index.php
123456789
[root@tianqi-01 111.com]# curl -x127.0.0.1:80 111.com/admin/index.php -I
HTTP/1.1 200 OK
Date: Sun, 04 Mar 2018 11:35:53 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
X-Powered-By: PHP/7.1.6
Content-Type: text/html; charset=UTF-8

[root@tianqi-01 111.com]# curl -x127.0.0.1:80 111.com/admin/index.php
123456789

[root@tianqi-01 111.com]# curl -x192.168.11.136:80 111.com/admin/index.php
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /admin/index.php
on this server.<br />
</p>
</body></html>

[root@tianqi-01 111.com]# curl -x192.168.11.136:80 111.com/admin/index.php -I
HTTP/1.1 403 Forbidden
Date: Sun, 04 Mar 2018 11:42:17 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# curl -x127.0.01:80 111.com/admin/index.php
123456789

[root@tianqi-01 111.com]# tail /usr/local/apache2.4/logs/111.com-access_20180304.log 
127.0.0.1 - - [04/Mar/2018:12:17:23 +0800] "HEAD HTTP://111.com/123.png.png1 HTTP/1.1" 404 - "-" "curl/7.29.0"
192.168.11.1 - - [04/Mar/2018:12:24:36 +0800] "GET / HTTP/1.1" 200 7 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3343.4 Safari/537.36"
192.168.11.1 - - [04/Mar/2018:12:24:49 +0800] "GET /eagle1jpg HTTP/1.1" 404 207 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3343.4 Safari/537.36"
192.168.11.1 - - [04/Mar/2018:16:09:54 +0800] "GET /favicon.ico HTTP/1.1" 404 209 "http://111.com/eagle1.jpg" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3343.4 Safari/537.36"
127.0.0.1 - - [04/Mar/2018:16:39:03 +0800] "HEAD HTTP://111.com/eagle1.jpg1 HTTP/1.1" 403 - "http://www.qq.com/123.txt" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:35:53 +0800] "HEAD HTTP://111.com/admin/index.php HTTP/1.1" 200 - "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:39:19 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 200 10 "-" "curl/7.29.0"
192.168.11.136 - - [04/Mar/2018:19:41:32 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 403 224 "-" "curl/7.29.0"
192.168.11.136 - - [04/Mar/2018:19:42:17 +0800] "HEAD HTTP://111.com/admin/index.php HTTP/1.1" 403 - "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:42:49 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 200 10 "-" "curl/7.29.0" 

[root@tianqi-01 111.com]# curl -x192.168.11.136:80 111.com/admin/index.php
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /admin/index.php
on this server.<br />
</p>
</body></html>
[root@tianqi-01 111.com]# curl -x192.168.11.136:80 111.com/admin/index.php -I
HTTP/1.1 403 Forbidden
Date: Sun, 04 Mar 2018 11:42:17 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# curl -x192.168.11.136:80 http://111.com/admin/adfafdafdas -I
HTTP/1.1 403 Forbidden
Date: Sun, 04 Mar 2018 11:44:49 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# curl -x127.0.0.1:80 http://111.com/admin/adfafdafdas -I
HTTP/1.1 404 Not Found
Date: Sun, 04 Mar 2018 11:53:35 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# 

//解釋說明

本機有兩個IP,一個是192.168.11.136,一個是127.0.0.1,經過這兩個IP均可以訪問到站點,而來源分別爲172.16.111.110和127.0.0.1,其實和本機IP是同樣的,curl測試狀態碼爲403則限制訪問了。

[root@tianqi-01 111.com]# !tail
tail /usr/local/apache2.4/logs/111.com-access_20180304.log 

127.0.0.1 - - [04/Mar/2018:16:39:03 +0800] "HEAD HTTP://111.com/eagle1.jpg1 HTTP/1.1" 403 - "http://www.qq.com/123.txt" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:35:53 +0800] "HEAD HTTP://111.com/admin/index.php HTTP/1.1" 200 - "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:39:19 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 200 10 "-" "curl/7.29.0"
192.168.11.136 - - [04/Mar/2018:19:41:32 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 403 224 "-" "curl/7.29.0"
192.168.11.136 - - [04/Mar/2018:19:42:17 +0800] "HEAD HTTP://111.com/admin/index.php HTTP/1.1" 403 - "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:42:49 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 200 10 "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:44:00 +0800] "HEAD http://111.com/admin/adfafdafdas HTTP/1.1" 404 - "-" "curl/7.29.0"
192.168.11.136 - - [04/Mar/2018:19:44:49 +0800] "HEAD http://111.com/admin/adfafdafdas HTTP/1.1" 403 - "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:51:53 +0800] "GET HTTP://111.com/admin/index.php HTTP/1.1" 200 10 "-" "curl/7.29.0"
127.0.0.1 - - [04/Mar/2018:19:53:35 +0800] "HEAD http://111.com/admin/adfafdafdas HTTP/1.1" 404 - "-" "curl/7.29.0"
[root@tianqi-01 111.com]# 

//解釋說明

瀏覽器訪問提示Forbidden,其實就是403,再來看日誌,能夠查看到對應的來源IP爲192.168.11.136,但願不要把來源IP和本機IP搞混了,前面實驗中之因此本機IP和來源IP同樣,就是由於它至關於本身訪問本身,然後面用瀏覽器訪問,至關於拿windows訪問。

11.27訪問控制FilesMatch

• 核心配置文件內容

<Directory /data/wwwroot/www.123.com>

    <FilesMatch  "admin.php(.*)">

        Order deny,allow

        Deny from all

        Allow from 127.0.0.1

    </FilesMatch>

</Directory>

1.針對某個文件來作限制。

[root@tianqi-01 111.com]# vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "/data/wwwroot/111.com"
    ServerName 111.com
    ServerAlias www.example.com 2111.com.cn
   # <Directory /data/wwwroot/111.com>
   #<FilesMatch 123.php>
        #AllowOverride AuthConfig
        #AuthName "111.com user auth"
        #AuthType Basic
        #AuthUserFile /data/.htpasswd
        #require valid-user
    #</FilesMatch>
    <Directory /data/wwwroot/111.com>
        <FilesMatch  "admin.php(.*)">
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
        </FilesMatch>
    </Directory>
    <Directory /data/wwwroot/111.com>
        SetEnvIfNoCase Referer "http://111.com" local_ref
        SetEnvIfNoCase Referer "http://ask.apelearn.com" local_ref
        SetEnvIfNoCase Referer "^$" local_ref
        <FilesMatch "\.(txt|doc|mp3|zip|rar|jpg|gif|png)">
            Order Allow,Deny
            Allow from env=local_ref
        </FilesMatch>
    </Directory>
    SetEnvIf Request_URI ".*\.gif$" img
    SetEnvIf Request_URI ".*\.jpg$" img
    SetEnvIf Request_URI ".*\.png$" img
    SetEnvIf Request_URI ".*\.bmp$" img
    SetEnvIf Request_URI ".*\.swf$" img
    SetEnvIf Request_URI ".*\.js$" img
    SetEnvIf Request_URI ".*\.css$" img
    CustomLog "|/usr/local/apache2.4/bin/rotatelogs -l logs/111.com-access_%Y%m%d.log 86400" combined env=!img
</VirtualHost>

2.檢測與法並從新加載配置

[root@tianqi-01 111.com]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
[root@tianqi-01 111.com]# /usr/local/apache2.4/bin/apachectl graceful
[root@tianqi-01 111.com]# 

3.實驗配置結果

[root@tianqi-01 111.com]# curl -x192.168.11.136:80 http://111.com/admin/adffffffsa -I
HTTP/1.1 404 Not Found
Date: Sun, 04 Mar 2018 12:04:24 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# curl -x192.168.11.136:80 'http://111.com/admin.php?adffffffsa' -I
HTTP/1.1 403 Forbidden
Date: Sun, 04 Mar 2018 12:06:16 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# curl -x127.0.0.1:80 'http://111.com/admin.php?adffffffsa' -I
HTTP/1.1 404 Not Found
Date: Sun, 04 Mar 2018 12:07:00 GMT
Server: Apache/2.4.29 (Unix) PHP/7.1.6
Content-Type: text/html; charset=iso-8859-1

[root@tianqi-01 111.com]# 

//這個404意味着已經容許訪問了

//總結:

這個和Directory的功能是一致的,可是有時候咱們僅僅是想有時候針對一個訪問的連接去作控制,那你再去控制目錄就不合適了,咱們須要適當靈活一些,知足一些個性化的需求。

友情連接:阿銘Linux

相關文章
相關標籤/搜索