99久久无码一区人妻A片贼王|99久久久久久久无码|99国产精品99久久久久久|97在线观看|97视频|8848高清电影电视剧免费看

299

Apache服務器設置防盜鏈的方法

時間: 2015-05-12 11:00:40   點擊數(shù): 36300   來源: 耐思智慧

首先,找到您的apache設置文件,一般情況下在 /usr/local/apache/conf/httpd.conf或者apache 2.2 的 /usr/local/apache2/conf/extra/httpd-vhost.conf,您可以酌情找到自己的conf文件,windows和freebsd下也一樣,然后找到類似如下內容:

這個是discuz X2.5自帶rewrite的規(guī)則

<VirtualHost *:80>

   DocumentRoot /home/www

   ServerName www.zhanhelp.com

  <IfModule mod_rewrite.c>

       RewriteEngine On

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/topic-(.+).html$ $1/portal.php?mod=topic&topicid=$2&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/(fid|tid)-([0-9]+).html$ $1/index.php?action=$2&value=$3&%1

</IfModule>

</VirtualHost>

這個是不帶rewrite的

<VirtualHost *:80>

   DocumentRoot /home/www

   ServerName www.zhanhelp.com

</VirtualHost>

在其中加入一段,具體內容如下:

SetEnvIfNoCase Referer "^http://www.zhanehlp.com" local_ref=1

SetEnvIfNoCase Referer "^http://zhanehlp.com" local_ref=1

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

Order Allow,Deny

Allow from env=local_ref

</FilesMatch>

其中站幫網的網站要更換成您的網址,如果有多個,就加多行;

txt|doc|mp3|zip|rar|jpg|gif的是您需要防盜鏈的文件后綴,中間用|隔開。


另外一種寫法,是用正則,這種寫法在各個版本的apache比較通用。具體寫法如下:

SetEnvIfNoCase Referer "^http://.*.zhanhelp.com" local_ref=1

SetEnvIfNoCase Referer ".*.zhanhelp.com" local_ref=1

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

Order Allow,Deny

Allow from env=local_ref

</FilesMatch>

其中網址的部分有一點區(qū)別,用正則寫法, 符號代表轉義,因為.本身在正則中有自己的作用。


最終改完防盜鏈+偽靜態(tài)規(guī)則后就會變成如下:

<VirtualHost *:80>

   DocumentRoot /home/www

   ServerName www.zhanhelp.com

   SetEnvIfNoCase Referer "^http://bbs.zb7.com" local_ref=1

   SetEnvIfNoCase Referer "^http://zhanhelp.com" local_ref=1

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

      Order Allow,Deny

      Allow from env=local_ref

  </FilesMatch>

  <IfModule mod_rewrite.c>

       RewriteEngine On

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/topic-(.+).html$ $1/portal.php?mod=topic&topicid=$2&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/article-([0-9]+)-([0-9]+).html$ $1/portal.php?mod=view&aid=$2&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/forum-(w+)-([0-9]+).html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/group-([0-9]+)-([0-9]+).html$ $1/forum.php?mod=group&fid=$2&page=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/space-(username|uid)-(.+).html$ $1/home.php?mod=space&$2=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+).html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3&%1

       RewriteCond %{QUERY_STRING} ^(.*)$

       RewriteRule ^(.*)/(fid|tid)-([0-9]+).html$ $1/index.php?action=$2&value=$3&%1

</IfModule>

</VirtualHost>

現(xiàn)在你的網站就可以徹底的仿制盜鏈了。

上一篇:IIS服務器防盜鏈具體設置方法 下一篇:服務器的php.ini在哪

旗下網站:耐思智慧 - 淘域網 - 我的400電話 - 中文域名:耐思尼克.cn 耐思尼克.top

耐思智慧 © 版權所有 Copyright © 2000-2025 IISP.COM,Inc. All rights reserved

備案號碼: 粵ICP備09063828號  公安備案號: 公安備案 粵公網安備 44049002000123號  域名注冊服務機構許可:粵D3.1-20240003 CN域名代理自深圳萬維網

聲明:本網站中所使用到的其他各種版權內容,包括但不限于文章、圖片、視頻、音頻、字體等內容版權歸原作者所有,如權利所有人發(fā)現(xiàn),請及時告知,以便我們刪除版權內容

本站程序界面、源代碼受相關法律保護, 未經授權, 嚴禁使用; 耐思智慧 © 為我公司注冊商標, 未經授權, 嚴禁使用

法律顧問:珠海知名律師 廣東篤行律師事務所 夏天風 律師

寿阳县| 龙川县| 六安市| 宾川县| 太原市| 磴口县| 辽源市| 宝应县| 韶山市| 连平县| 金湖县| 博兴县| 五大连池市| 桂林市| 宜黄县| 襄汾县| 密云县| 木里| 陕西省| 北海市| 交城县| 慈利县| 武城县| 湖州市| 洛川县| 日照市| 交城县| 新余市| 通道| 巫山县| 澄迈县| 定结县| 新乡市| 湘阴县| 健康| 绿春县| 永丰县| 得荣县| 垣曲县| 延寿县| 衡山县|