2017年 9月 26日
歡迎 ! 新來賓
[ 登入 ]
主頁 | 客戶中心 | 技術支援中心
訂閱 RSS | 設為首頁 | 加入最愛
資料搜尋:
瀏覽:

如何防範「圖片外連」及「頻寬偷竊」

建立日期: 2009年 7月 18日   (8 年前) 閱讀次數: 1001 評價: 

概覽

如何防範「圖片外連」及「頻寬偷竊」
點擊這裡放大“圖片”
如何防範「圖片外連」及「頻寬偷竊」
If you find your site is running very slowly, there are measures you can take to bandwidth protect.

You can stop others from hotlinking your website files by placing a file called .htaccess in your Apache site root (main) directory. The period before the name means the file is hidden, so you may want to edit your file as htaccess.txt, upload it to your server, then rename the txt file to .htaccess in your directory.

Example: Your website URL is www.domainname.com. To stop hotlinking of your images from other sites and display a replacement image called nohotlink.jpe placed in your images directory, place this code in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+.)?domainname.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

The first line of the above code begins the rewrite. The second line matches any requests from your own domainname.com URL. The [NC] code means "No Case", meaning match the url regardless of being in upper or lower case letters. The third line means allow empty referrals. The last line matches any files ending with the extension jpeg, jpg, gif, bmp, or png. This is then replaced by the nohotlink.jpe file in your images directory. This JPEG image is using the extension jpe instead of jpg to prevent blocking your own replacement image.

To stop hotlinking from specific outside domains only, such as myspace.com, blogspot.com and livejournal.com, but allow any other web site to hotlink images:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://(.+.)?myspace.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?blogspot.com/ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://(.+.)?livejournal.com/ [NC]
RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

You can add as many different domains as needed. Each RewriteCond line should end with the [NC,OR] code. NC means to ignore upper and lower case. OR means "Or Next", as in, match this domain or the next line that follows. The last domain listed omits the OR code since you want to stop matching domains after the last RewriteCond line.

You can display a 403 Forbidden error code instead of an image. Replace the last line of the previous examples with this line:

RewriteRule .*.(jpe?g|gif|bmp|png)$ - [F]

As with any htaccess rewrites, you may block some legitimate traffic (such as users behind proxies or firewalls) using these techniques.
注意事項
  • Do not use .htaccess to redirect image hotlinks to another HTML page or server that isn't your own (such as this web page). Hotlinked images can only be replaced by other images, not with an HTML page.
  • 以上所指的domainname請替換成您的域名。
*** 以上提供的資料僅供參考,如有需要,請諮詢獨立技術顧問的意見。
這文章對您有幫助嗎?
您可以加進最愛的書籤:DiggredditDeliciousGoogle BookmarksWindows LiveFacebookSlashdot BookmarksPropellerTechnoratiBlinkListYahoo bookmarksMa.gnoliaSquidoo
靜態連結:  
 
ec2Biz.com 互動多媒體、網頁寄存、網上商店、域名註冊、電子商貿方案 | Ecommerce Web Hosting Solutions
©2017 Focus Network Company. 版權所有 不得轉載