¬Û«H±M·~¡Aµ¹§A«~½è
±MÀç«Ø¿vª«¨¾¤ô¡B§ìº|¡B°£¾ÀÀù¡B©î°£¤uµ{
§N®ðª½±µ´£¨Ñ«È¤áµ¹±z¡A¨C¤Ñ´£¨Ñµ¹±z·s«È¤á±a¨Ó·s°Ó¾÷
¤£¥Î¦Aªá°ªÃBªº¼s§i¶O°µ¨Ç¨S®ÄªGªº¼s§i

­º­¶  ¡E  j2h ½×¾Â ¡E µ{¦¡³]­p°Q½×     ¡E 

­­¨î¹Ï¤ù¥~³s¥Î .htaccess Àɮײ£¥Í¾¹

©ÐªF¡GÀsÀs
µoªí®É¶¡¡G2007-01-18


¤@¯ëÀW¼e¦³­­ªº½×¾Â³£§Æ±æ¹Ï¤ù¤£­n¥~³s¡A¦Ó§@ªk¬O«Ø¥ß¤@­Ó .htaccess Àɮשñ¦b½×¾Â¥Ø¿ý¤U

©³¤U³o¤@­Ó³sµ²¬OÀ°§U§A²£¥Í .htaccess ÀɮץΪº

http://www.htmlbasix.com/disablehotlinking.shtml



  • ÃÙ§Uºô¯¸       

    ¼s§Q¤£°Ê²£-ªO¾ô¦b¦a¥Í®Ú³Ì¹ê¦b--·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    §¹¾ã©Ð°T¡A©Ð«Î¡B©±­±¼öªùºë¿ïª«¥ó¡A¼s§Q¤£°Ê²£ Àu½è¥ò¤¶¡A©Ð«Î¯²¸î¡B¶R½æ¸ê°T³z©ú¡A¥æ©ö¯u¦w¤ß¡I
    ¼s§Q¤£°Ê²£-·sªO¯S°Ï«ü¦W«×³Ì°ª¡B­È±o±z«H¿àªº¦n©Ð¥ò
    ±zªº¦«¥I,¼s§Q¥Î¤ß¬°±zªA°È

  • 1 ¼Ó¦í¤á¡G°ª¤â
    µoªí®É¶¡¡G2007-01-27

    ¥Î mod_rewrite ¨¾¤î°½¹Ï¥H«e§Ú¦³¤@¦ì«È¤á¡A¥Lªººô¯¸¬y¶q¤Q¤À¤j¡A¸g¹LÀˬd«áµoı¤j³¡¥÷ªº¬y¶q³£¥Î¦b¹Ï¤ù¤W¡A³o¤]µL¥i«p«D¡A¥Lªº¹Ï¤ù¸Ñ¹³«×¤ñ¸û°ª¡A¦ý¥t¤@­Ó­ì¦]¬O¦³¤H¦b¨ä¥L½×¾Â¶K¤W¥Lªº¹Ï¤ù¡A¦Ó¶K¹Ïªº¤èªk¬Oª½±µ¨Ï¥Î¥Lªº¹Ï¤ù³sµ²¡C§Ú°Ý¹L¥Lªº·N¨£¡A¥L¤£¤¶­±§O¤H¶K¥X¥Lªº¹Ï¤ù¡Aª½±µ¤U¸ü¹Ï¤ù¦A­«·s¤W¸üªº¸Ü¨S¦³°ÝÃD¡A¦]¬°¨C±i¹Ï¤ù¤]¦³¥X²{¥Lªººô¯¸¦WºÙ¡A¥u¬O¤£·Q¤H®a®ö¶O¤F¥Lªº¬y¶q¡C

    µM«á§Úı±o¥Î mod_rewrite ¬O¸û¤è«Kªº°µªk¡A¦Ó¦pªG§Aªººô¯¸¤]¤ä´© mod_rewrite ¥\¯à¡A¦b .htaccess ¥[¤W¥H¤U¤º®e¡A¤]¥i¨¾¤îµ¹§O¤H°½¹Ï:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://www.anotherwebsite.com/.*$ [NC]
    RewriteRule ^/img/indieband\.jpg$ http://www.mydomain.com/nkotb.jpg [R]

    ¥H¤Wªº²Ä¤@¦æ¬O¶}©ñ RewriteEngine¡A¦pªG§Aªº .htaccess ¤w¸g¦³³o¤@¦æ´N¤£¥Î¥[¤W¡F²Ä¤G¦æ¬O¨ä¥Lºô¯¸ªººô§}¡F²Ä¤T¦æ¬O±N /img/indieband.jpg ¾É¦V /nkotb.jpg¡A¦Ó³o­Ó /nkotb.jpg ¥i¥H¬O»¡©ú¹Ï¤ù¥X³Bªº¹Ï¤ù¡C


    2 ¼Ó¦í¤á¡G°ª¤â
    µoªí®É¶¡¡G2007-01-27

    ²©ö§@ªk
    ¦bServer¤W³]©wReferer¨¾°ô¡A
    «Ü¦h¤Hª¾¹D­n¦b.htaccess¤W°Ê¤â¸}¡A³]©w


    SetEnvIfNoCase Referer "^http://([^/]*\.)?your.server.name/" local_referrer=1
    Order Allow,Deny
    Allow from env=local_referrer


    ´N¥i¥H®Ú¾ÚReferer¨¾¤îjpgµ¥Àɮ׳Qµs³s



    [½s¿è]»¡©ú
    ³]©w Apache mod_rewrite ¨Ó¨¾¤îmod_rewrite on

    ¶}±Ò .htaccess Åv­­
    1.¶}±Ò httpd.conf
    2.·j´M AllowOverride None¡A©Î¬O¥u·j´M AllowOverride ÃöÁä¦r
    3. §â None §ï¦¨ ALL¡Aªí¥Ü§¹¥þ±µ¨ü .htaccess ùتº©Ò¦³Åv­­³]©w¡AµM«á¦sÀÉ

    ¼W¥[¥H¤U¤º®eªº .htaccess ÀÉ¡A©ñ¦bºô¯¸¥Ø¿ý¤U§Y¥i¡C

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://lym.fyman.idv.tw(.*) [NC]
    RewriteRule \.(jpg|jpeg|gif|css|swf|png|bmp|rar|zip|exe)$ - [F]

    ²Ä¤@¦æ¬°¶}±Ò RewriteEngine¡A¤G¤T¦æ³]©w¤¹³\ªº³s½u
    ²Ä¥|¦æ«h¬O±q¨ä¥L¦a¤è³s¶i¨Ó¥B¬O¨º¨ÇÀɦWªº¡A¬Ý¨ì403¿ù»~°T®§¡A¤]¥i¥H§ï¦¨Åã¥Ü«ü©wªº¹Ï¤ù¡C


    ©Î¬O¦bºô¯¸¥Ø¿ý¤Uªº .htaccess Àɤ¤¡B©Î httpd.conf Àɤ¤¥[¤J¤U¦C¤º®e§Y¥i¡G

    µ{¦¡½X

    SetEnvIfNoCase Referer "^http://yourdomain.com/" local_referrer=1
    Order Allow,Deny
    Allow from env=local_referrer


    °O±o§â http://yourdomain.com/ ³o¤@¬q§ï¦¨¦Û¤vªººô¯¸ URL
    [½s¿è]±q³]©wÀɤU¤â
    ª`·N!¥»±Ð¾Ç¥u°w¹ïapacheµ{¦¡¬[³]ªº¥D¾÷¦³®Ä!


    ½Ð­×§ï apache ¤¤ªº httpd.conf
    ½Ð§ä¨ì¤U¦C¤å¦r:

    Options All
    AllowOverride All



    ­×§ï¬°:

    Options FollowSymLinks Includes
    AllowOverride AuthConfig Limit

    Order allow,deny
    Allow from all

    SetEnvIfNoCase Referer \"^http://www1.xxx.com/ (http://www1.xxx.com/)\" local_ref=1
    SetEnvIfNoCase Referer \"^http://www2.xxx.com/ (http://www2.xxx.com/)\" local_ref=1

    Order Allow,Deny
    Allow from env=local_ref




    ¨ä¤¤ªºhttp://www1.xxx.com/¬°±z±ý³]­­ªººô§},¥i¼W¥[´î¤Ö...
    ¦A¨ä¤¤ªº(gif|jpg|jpeg|JPG|GIF|JPEG)¤º¬°±ý³]­­ªºÀÉ®×°ÆÀɦW,±z¥i¦Û¦æ­×§ï!


    ¦ý­n°O±o, ¦pªG§Aºô­¶¤¤¦³¨Ï¥Î¨ä¥Lµ{¦¡¨Ó©I¥sµ´¹ï¸ô®|ªº¹Ï¤ù®É,
    ½Ð¤@«ß­×§ï¦¨¬Û¹ï¸ô®|, §_«h¨º¨Ç¹Ï¤ù¤]·|Åܦ¨¤e¿N¥]ªº.




    ¡@¦@ 2 ¤H¦^À³¡@¡@¿ï¾Ü­¶¼Æ ¡i²Ä1 ­¶¡j 

    ©m¦W¡G
    §G§i¤º®e¡G
    ¨ä¥L¿ï¶µ: