Seize the day, enjoy my life! 注册 | 登陆
浏览模式: 标准 | 列表2009年02月20日的文章

.htaccess 学?笔?

.htaccess可以做大量范?的事情,包括:文件?密?保?、用?自?重新指向、自定????面、?更你的文件?展名、屏蔽特定的用?IP地址、只允?特定的IP地址、停止目?表以及使用其他文件作?index文件,等等......

1. Introduction 介?
文件名 .htaccess 属性 644 (RW-R–R–)
htaccess会影响它所在目?下的所有子目?
注意大多数内容都要求保持在一行之内,不要?行,否?会引起??

2. Error Documents ??文档
Official document: ErrorDocument Directive
ErrorDocument code document
例子
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 404 http://yoursite/errors/notfound.html
ErrorDocument 401 “Authorization Required”
(注意之后内容如果出?的双引号需要??? \”)
常?HTTP状??
Successful Client Requests
200 OK
201 Created
202 Accepted
203 Non-Authorative Information
204 No Content
205 Reset Content
206 Partial Content
Client Request Redirected
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy
Client Request Errors
400 Bad Request
401 Authorization Required
402 Payment Required (not used yet)
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable (encoding)
407 Proxy Authentication Required
408 Request Timed Out
409 Conflicting Request
410 Gone
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type
Server Errors
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported

3. Password Protection 密?保?
Official document: Authentication, Authorization and Access Control
假?密?文件?.htpasswd
AuthUserFile /usr/local/safedir/.htpasswd (?里必?使用全路径名)
AuthName EnterPassword
AuthType Basic
两?常???方式:
Require user windix
(?允?用?windix登?)
Require valid-user
(所有合法用?都可登?)
Tip: 如何生成密?文件
使用htpasswd命令(apache自?)
第一次生成需要?建密?文件
htpasswd -c .htpasswd user1
之后?加新用?
htpasswd .htpasswd user2

4. Enabling SSI Via htaccess 通?htaccess允?SSI(Server Side Including)功能
AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
DirectoryIndex index.shtml index.html

5. Blocking users by IP 根据IP阻止用???
order allow,deny
deny from 123.45.6.7
deny from 12.34.5. (整个C?地址)
allow from all

6. Blocking users/sites by referrer 根据referrer阻止用?/站点??
需要mod_rewrite模?
例1. 阻止?一referrer: badsite.com
RewriteEngine on
# Options  FollowSymlinks
RewriteCond %{HTTP_REFERER} badsite\.com [NC]
RewriteRule .* - [F]
例2. 阻止多个referrer: badsite1.com, badsite2.com
RewriteEngine on
# Options  FollowSymlinks
RewriteCond %{HTTP_REFERER} badsite1\.com [NC,OR]
RewriteCond %{HTTP_REFERER} badsite2\.com
RewriteRule .* - [F]
[NC] - 大小写不敏感(Case-insensite)
[F] - 403 Forbidden
注意以上代?注?掉了”Options  FollowSymlinks”?个?句。如果服?器未在 httpd.conf 的 段落?置 FollowSymLinks, ?需要加上?句,否?会得到”500 Internal Server error”??。

7. Blocking bad bots and site rippers (aka offline browsers) 阻止坏爬虫和离???器
需要mod_rewrite模?
坏爬虫? 比如一些抓垃圾email地址的爬虫和不遵守robots.txt的爬虫(如baidu?)
可以根据 HTTP_USER_AGENT 来判断它?
(但是?有更无耻的如”中搜 zhongsou.com”之流把自己的agent?置? “Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)” 太流氓了,就无能?力了)
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
[F] - 403 Forbidden
[L] - ?

8. Change your default directory page 改?缺省目??面
DirectoryIndex index.html index.php index.cgi index.pl

9. Redirects ?向
?个文件
Redirect /old_dir/old_file.html http://yoursite.com/new_dir/new_file.html
整个目?
Redirect /old_dir http://yoursite.com/new_dir
效果: 如同将目?移?位置一?
http://yoursite.com/old_dir -> http://yoursite.com/new_dir
http://yoursite.com/old_dir/dir1/test.html -> http://yoursite.com/new_dir/dir1/test.html
Tip: 使用用?目??Redirect不能?向的解决方法
当你使用Apache默?的用?目?,如 http://mysite.com/"windix,当你想?向 http://mysite.com/"windix/jump?,你会??下面?个Redirect不工作:
Redirect /jump http://www.google.com
正确的方法是改成
Redirect /"windix/jump http://www.google.com
(source: .htaccess Redirect in “Sites” not redirecting: why?
)

10. Prevent viewing of .htaccess file 防止.htaccess文件被?看
order allow,deny
deny from all

11. Adding MIME Types 添加 MIME ?型
AddType application/x-shockwave-flash swf
Tips: ?置?型? application/octet-stream 将提示下?

12. Preventing hot linking of images and other file types 防盗?
需要mod_rewrite模?
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www/\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg|js|css)$ - [F]
解析:
若 HTTP_REFERER 非空 (来源?其他站点,非直接?接) 并且
若 HTTP_REFERER 非(www.)mydomain.com??(忽略大小写[NC]) (来源非本站)
?于所有含有 .gif/.jpg/.js/.css ?尾的文件?出 403 Forbidden ??[F]
也可指定响?,如下例?示替??片
RewriteRule \.(gif|jpg)$
[R,L]
[R] - ?向(Redirect)
[L] - ?接(Link)

13. Preventing Directory Listing 防止目?列表??示
IndexIgnore *
IndexIgnore *.jpg *.gif
Tips:
允?目?列表?示: Options  Indexes
禁止目?列表?示: Options -Indexes
?示提示信息: ?首 文件HEADER, ?尾 文件README

80后北京人月薪3000?房???老婆!

我是北京人,父母都是大学教授,所以家庭条件?算?越。我和老婆是大学同学,她来自南方小城市,父母都是?民,家庭条件很不好。从我?从一起的第一天就遭我父母?烈反?,直到?婚那天,父母也没有完全?可她。真搞不懂,他?天天?口的仁?道?,?什?事儿?在自己身上的?候又?得?力起来了。不??好喜宴的?是父母出的,新房的首付、?装、家具共?35万元,也是由我父母出的。老?口也算仁至?尽了,再多的我?也是在没?再管他?要,反正从决定?婚那天起,我?就已?做好了挨几年苦日子的准?。

大学??后我就?了一家私企当??,一年半加薪3次,如今去5?税后3000元,老婆很上?,考上了研究生,除了学校?月?助的200?外没有收入。得,不?那?多了,直入主?!就?一月3000元,看我怎????房?老婆!
  
?房

我?的新房在通?,50平米,去除首付外,?款15万,?款二十年,月供1000元出一点?。
水?:8—9吨,?30元/月
??:70度左右,?35元/月
燃气?:10个字左右,?25元/月
??及座机??:150元/月
合?:1240元/月
  
??

3个月前老婆?孕了,我父母?了尽早抱?子?持要我?把?个孩子生下来,因?担心老婆?天?公交?胎儿不好,父母决定送我?一??,但是??的?用他?不管。考?了良久,我也?得老婆肚子一天天大了,??很危?也不方便,但是??太?,油价也一天天?升,?然??父母?他?出,但是我?也?是必??????惠型的,最后?了一款油耗很低的微型?比?迪F0。
油?(上、下班,周末偶?外出):450元左右
?路?:110元/月
?船使用税(480元/年):40元/月
交??+常?保?(2700元/年):?225元0/月
洗??(周末我和老婆自己洗?):0元/月
保?:?50元/月
停??(小区内?主免?、?位有免?停?位):30元左右
合?:905元
  
?自己和老婆

我老婆从小生活很拮据,??了省吃?用的??,很会?日子,剩下的不到一千元,我?两个生活?然?了点,但在她的尽心安排下?是?用的。
手机?(她30元,我50元):80元/月
伙食?(??她在家做、中午我公司?定盒?):350元/月
水果、零食:100元/月
??、?酬(极少):200元/月
衣服(很少?、或者去?物园淘):150元/月
日用品:50元/月
合?:930
  
?房+??+?自己和老婆=1240+820元+930元=3075元

算一算再?3个月又?到加薪的?候了,但金融危机?得?害,可能??加薪无望,老婆??期在6月,那?如果??危机?和些??会有加薪机会,?划?加的薪水全部用作孩子的生活??。明年1月又要取消?路??船使用?等一大笔?用,再加上老婆?有一年半就??了,等老婆工作了,我?就能?裕些了。?在?然?力很大,?天工作也很辛苦,但是一想到老婆孩子真的非常有?力,吼吼,何况好日子也不遥?了,近在咫尺。

??3000元就不能在北京?房???老婆?80后,牛×!努力ING!

瑞星2009免?使用特?面?所有QQ会?

活???:
  • 瑞星2009免?使用特?面?所有QQ会?。
    活????即日-2009.3.12。
  • 所有QQ会?用?登?激活自己的会?号?后即可参与活?,?一位会?根据其??的等?只能?取一次瑞星?毒?件2009激活注册序列号。
  • VIP1-VIP5可免?使用3个月,VIP6可免?使用6个月。(提示:?于一年内激活所?取的序列号)。
  • 使用方法:
    a,下?安装包
    b,?入?品序列号和用?ID
    c,升?使用。
  • 3个月序列号?天上限?9333个,6个月序列号?天上限?667个。
  • 活?疑??咨???客服??0755-83765566,本活?解???瑞星、??公司所有。

http://act.vip.qq.com/2009/ruixing/index.html