我即將啓動一個攝影網站,並希望對我的圖像提供一些保護。我有以下爲在網絡上搜索的結果:使用htaccess進行圖像保護
#Set FollowSymLinks, in most cases already set on the server
Options +FollowSymLinks
#Enable Indexes
Options +Indexes
#Turn on the Rewrite Engine
RewriteEngine on
#Allow my domain
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?mydomain.com [NC]
#Allow another domain
#RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?anotherdomain.com [NC]
#Allow blank referrers or delete this line to block them
#Deleting this line also blocks access to images by filepaths
RewriteCond %{HTTP_REFERER} !^$
#Allow search engines
RewriteCond %{HTTP_REFERER} !google. [NC]
RewriteCond %{HTTP_REFERER} !search?q=cache [NC]
RewriteCond %{HTTP_REFERER} !msn. [NC]
RewriteCond %{HTTP_REFERER} !yahoo. [NC]
#File types to be blocked
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]
#OR
#First allow an image to be hotlinked to avoid looping
#RewriteCond %{REQUEST_URI} !^mydomain.com/image/hotlinker.gif$
#Then display it as a custom image
#RewriteRule .(jpg|jpeg|png|gif)$ mydomain.com/image/hotlinker.gif [NC,R,L]
1)是否有辦法阻止它的文件路徑的條目,不涉及堵空白引薦被稱爲了一個形象?我有幾個我想要這樣做的例子,但不是整個網站。
2)我是否有正確的代碼允許谷歌,MSN和雅虎正確訪問我的圖片?
3)我擁有的代碼是從多個源合併而成的。由於我對語法沒有任何瞭解,所以我想知道爲什麼只有沒有替代映像的第一個RewriteRule以\開頭,而不是第二個?
感謝任何反饋,謝謝。
感謝喬恩的幫助,我很感激。我已經發布了一些更多的回答我的問題。 – martin
如果我沒有遵循正確的協議回答我自己的問題,我會道歉嗎?我沒有看到我如何能夠把它作爲一個評論。 – martin
依靠HTTP_REFERRER安全嗎? – Geo