[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$f7X92XrM9qywQ_JGAGtg71rM5LpFfkR0msGiCxB6cOD0":3},{"code":4,"msg":5,"data":6},0,"success",{"id":7,"title":8,"description":9,"keywords":10,"commentId":11,"isOriginal":12,"isCopyable":13,"view":14,"publish_time":15,"update_time":15,"content":16},13,"apache .htaccess文件详解和配置技巧总结","一、.htaccess的基本作用\r.htaccess是一个纯文本文件，它里面存放着Apache服务器配置相关的指令。.htaccess主要的作用有：URL重写、自定义错误页面、MIME类型配置以及访问权限控制等。主要体现在伪静态的应用、图片防盗链、自定义404错误页面、阻止\u002F允许特定IP\u002FIP段、目录浏览与主页、禁止访问指定文件类型、文件密码保护等。.htaccess的用途范围主要针对当前目录。\r…","apache,htaccess,服务器,运维,阿里云,腾讯云",17,false,true,413,1672821882,{"frontmatter":17,"meta":18,"nodes":19},{},{},[20],[21,22,23,34,47,65,86,147,154,164,173,177,184,188,192,202],"p",{},[21,24,28],{"$":25,"style":27},{"html":26,"block":4},1,"padding: 0px; margin: 13px auto; font-family: -apple-system, BlinkMacSystemFont, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.015em; font-feature-settings: 'tnum'; font-variant-numeric: tabular-nums; font-variant-east-asian: normal; line-height: 1.8; word-break: break-word; color: #23263b; background-color: rgba(255, 255, 255, 0.9);",[29,30,33],"strong",{"$":31,"style":32},{"html":26,"block":4},"padding: 0px; margin: 0px;","一、.htaccess的基本作用",[21,35,37,38,42,43,46],{"$":36,"style":27},{"html":26,"block":4},".htaccess是一个纯文本文件，它里面存放着Apache服务器配置相关的指令。",[39,40],"br",{"$":41,"style":32},{"html":26,"block":4},".htaccess主要的作用有：URL重写、自定义错误页面、MIME类型配置以及访问权限控制等。主要体现在伪静态的应用、图片防盗链、自定义404错误页面、阻止\u002F允许特定IP\u002FIP段、目录浏览与主页、禁止访问指定文件类型、文件密码保护等。",[39,44],{"$":45,"style":32},{"html":26,"block":4},".htaccess的用途范围主要针对当前目录。",[21,48,50,53,60,61,64],{"$":49,"style":27},{"html":26,"block":4},[39,51],{"$":52,"style":32},{"html":26,"block":4},[29,54,56,57],{"$":55,"style":32},{"html":26,"block":4},"二、启用.htaccess的配置",[39,58],{"$":59,"style":32},{"html":26,"block":4},"启用.htaccess，需要修改httpd.conf，启用AllowOverride，并可以用AllowOverride限制特定命令的使用。",[39,62],{"$":63,"style":32},{"html":26,"block":4},"打开httpd.conf文件用文本编辑器打开后,查找 ",[66,67,71,79,85],"div",{"$":68,"class":69,"style":70},{"html":26,"block":4},"codetitle","padding: 0px; margin: 0px; color: #23263b; font-family: -apple-system, 'SF UI Text', Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 15.5px; background-color: rgba(255, 255, 255, 0.9);",[72,73],"a",{"$":74,"id":75,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut10264","copybut","padding: 0px; margin: 0px; color: #5c8ec6; outline: 0px;","noopener",[80,81,84],"span",{"$":82,"style":83},{"html":26,"block":4},"padding: 0px; margin: 0px; text-decoration-line: underline;","复制代码","代码如下:",[66,87,89,94,97,101,104,108,111,115,118,122,125,128,131,134,137,141,144],{"$":88,"class":69,"style":70},{"html":26,"block":4},[90,91,93],"code",{"$":92},{"html":26,"block":4},"\u003CDirectory \u002F>",[39,95],{"$":96,"style":32},{"html":26,"block":4},[90,98,100],{"$":99},{"html":26,"block":4},"Options FollowSymLinks",[39,102],{"$":103,"style":32},{"html":26,"block":4},[90,105,107],{"$":106},{"html":26,"block":4},"AllowOverride None",[39,109],{"$":110,"style":32},{"html":26,"block":4},[90,112,114],{"$":113},{"html":26,"block":4},"\u003C\u002FDirectory>",[39,116],{"$":117,"style":32},{"html":26,"block":4},[90,119,121],{"$":120},{"html":26,"block":4},"改为：",[39,123],{"$":124,"style":32},{"html":26,"block":4},[90,126,93],{"$":127},{"html":26,"block":4},[39,129],{"$":130,"style":32},{"html":26,"block":4},[90,132,100],{"$":133},{"html":26,"block":4},[39,135],{"$":136,"style":32},{"html":26,"block":4},[90,138,140],{"$":139},{"html":26,"block":4},"AllowOverride All",[39,142],{"$":143,"style":32},{"html":26,"block":4},[90,145,114],{"$":146},{"html":26,"block":4},[21,148,150,153],{"$":149,"style":27},{"html":26,"block":4},[39,151],{"$":152,"style":32},{"html":26,"block":4},"如果需要使用.htaccess以外的其他文件名，可以用AccessFileName指令来改变。例如，需要使用.config ，则可以在服务器配置文件中按以下方法配置：",[66,155,157,161,85],{"$":156,"class":69,"style":70},{"html":26,"block":4},[72,158],{"$":159,"id":160,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut1978",[80,162,84],{"$":163,"style":83},{"html":26,"block":4},[66,165,169],{"$":166,"id":167,"class":168,"style":70},{"html":26,"block":4},"code1978","codebody",[90,170,172],{"$":171},{"html":26,"block":4},"AccessFileName .config",[21,174,176],{"$":175,"style":27},{"html":26,"block":4}," ",[21,178,180],{"$":179,"style":27},{"html":26,"block":4},[29,181,183],{"$":182,"style":32},{"html":26,"block":4},"三、.htaccess访问控制",[21,185,187],{"$":186,"style":27},{"html":26,"block":4},"1、访问控制基础：Order命令",[21,189,191],{"$":190,"style":27},{"html":26,"block":4},"      为了限制用户访问一些关键目录，通常加入.htaccess文件，常见的写法如下：",[66,193,195,199,85],{"$":194,"class":69,"style":70},{"html":26,"block":4},[72,196],{"$":197,"id":198,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut79951",[80,200,84],{"$":201,"style":83},{"html":26,"block":4},[80,203,204,205,208,209,212,213,218,221,224,225,228,231,232],{},"|%",[80,206,207],{},"0-9A-Z",") ",[80,210,211],{},"OR","  ",[90,214,216,217],{"$":215},{"html":26,"block":4},"RewriteCond %"," GLOBALS(=|",[39,219],{"$":220,"style":32},{"html":26,"block":4},[39,222],{"$":223,"style":32},{"html":26,"block":4},"# 阻止企图通过URL设置PHP的_REQUEST变量的脚本  ",[90,226],{"$":227},{"html":26,"block":4},[39,229],{"$":230,"style":32},{"html":26,"block":4},"RewriteCond % _REQUEST(=|",[72,233,204,235,237,238,241,244,247,248,251,254,255,1556,1557,449,1561,449,1565,21,1569,1573,1574,1578,1579,1583,1587,1578,1593,1597,1601,72,1605,1609,1610,399,1614,399,1618,409,1622,389,1626,399,1630,449,1634,1578,1638,1642,1646,1650,1654,1658,1662,1667,1668,1671,1676,1677,1680,1684,1687,1688,1691,1692,1695,84,1699,85,1702,1705,1706,1709,1712,1713,1716,1719,1720,1723,1726,1727,1730,1734,1737,1738,1741,1742,1745,84,1749,85,1752,1755,1756,1759,1762,1763,1766,1769,1770,1773,1776,1777,1780,1783,1784,1787,1790,1791,1794,1797,1798,1801,1804,1805,1808,1811,1812,1815,1818,1819,1822,1826,1829,1830,1833,1834,1837,84,1841,85,1844,1847,1848,1851,1854,1855,1858,1861,1862,1865,1869,1872,1873,1876,1877,1880,84,1884,85,1887,1890,1891,1894,1897,1898,1901,1904,1905,1908,1861,1911,1914,1918,1921,1924,1928,1929,1935,1938],{"href":234},"comark:incomplete-link",[80,236,207],{},")  ",[90,239],{"$":240},{"html":26,"block":4},[39,242],{"$":243,"style":32},{"html":26,"block":4},[39,245],{"$":246,"style":32},{"html":26,"block":4},"# 把所有被阻止的请求转向到403禁止提示页面！  ",[90,249],{"$":250},{"html":26,"block":4},[39,252],{"$":253,"style":32},{"html":26,"block":4},"RewriteRule ^(.",[256,257,258,259,262,1267,1270,1271,1274,1275,1278,1279,1282,1285,1286,1289,1292,1293,1296,1299,1300,1303,1306,1307,1310,1313,1316,1317,1320,1323,1324,1327,1292,1330,1333,1299,1336,1339,1306,1342,1345,1348,1351,1352,1355,1358,1359,1362,1365,1366,1369,1372,1373,1376,1379,1380,1383,1386,1387,1390,84,1394,85,1397,1400,1401,1404,1407,1408,1411,1414,1415,1418,176,1422,1425,1428,1429,1432,1435,1436,1439,1440,1443,1444,1447,1448,1451,1452,1455,84,1459,85,1462,1465,1466,1469,1473,1476,1477,1480,1481,1484,84,1488,85,1491,1494,1495,1498,1501,1502,1505,1508,1509,1512,1516,1519,1520,1523,1524,1527,84,1531,85,1534,1167,1537,1540,1045,1543,1546,1549,1550,1553,254],"em",{},")$ index.php [F,L] ",[90,260],{"$":261},{"html":26,"block":4},[66,263,266,1230,1233,1236,1240,1243,1254,1257,1260,1264],{"$":264,"id":265,"class":168,"style":70},{"html":26,"block":4},"code89969",[90,267,269,208,1228,212],{"$":268},{"html":26,"block":4},[256,270,271,272,275,276,279,280,284,287,288,291,294,295,298,301,302,305,176,308,311,312,315,316,1227],{},".([Ll][Oo]",[80,273,274],{},"Gg",")|([eE][xX]",[80,277,278],{},"eE",")\">",[90,281,283],{"$":282},{"html":26,"block":4},"\u003CFiles  ~ \"^.",[39,285],{"$":286,"style":32},{"html":26,"block":4}," Order allow,deny",[90,289],{"$":290},{"html":26,"block":4},[39,292],{"$":293,"style":32},{"html":26,"block":4}," Deny from all",[90,296],{"$":297},{"html":26,"block":4},[39,299],{"$":300,"style":32},{"html":26,"block":4},"\u003C\u002FFiles>",[90,303],{"$":304},{"html":26,"block":4},[66,306],{"$":307,"class":69,"style":70},{"html":26,"block":4},[21,309],{"$":310,"style":27},{"html":26,"block":4},"说明：",[21,313],{"$":314,"style":27},{"html":26,"block":4},"（1）Files后的波浪线表示启用“正则表达式”，简单的写法有：\u003CFiles ",[256,317,318,319,322,323,326,327,330,333,334,337,84,341,85,344,347,348,352,355,358,359,362,365,368,369,372,375,378,379,382,383,389,390,394,395,399,400,404,405,409,410,21,416,421,422,21,426,430,431,21,435,439,440,444,445,449,450,454,458,459,463,467,471,394,477,481,482,487,492,496,500,506,507,513,521,522,525,528,531,532,21,536,72,540,544,545,399,549,409,553,21,557,421,561,21,565,430,569,573,577,581,585,590,591,594,599,600,603,606,609,612,613,176,616,619,620,623,626,627,630,84,634,85,637,640,641,644,647,648,651,654,655,658,661,662,665,668,669,672,176,675,678,679,682,685,686,689,690,693,694,697,698,701,84,705,85,708,711,712,715,719,722,723,726,727,730,731,734,84,738,85,741,744,745,748,752,755,756,759,760,763,84,767,85,770,773,774,777,781,784,785,788,789,792,84,796,85,799,802,803,806,810,813,814,817,818,821,822,825,826,829,84,833,85,836,839,840,844,845,848,852,855,856,859,860,863,84,867,85,870,873,874,877,881,884,885,888,84,892,85,895,898,899,902,906,909,910,913,84,917,85,920,923,924,927,931,934,935,938,84,942,85,945,948,949,952,956,959,960,963,84,967,85,970,973,974,977,981,984,985,988,84,992,85,995,998,999,1002,1006,1009,1010,176,1013,1016,1017,1020,1023,1024,1027,1028,1031,1032,1035,84,1039,85,1042,1045,1046,1049,1052,1053,399,1057,1061,1062,1066,1067,458,1071,449,1075,399,1079,1083,1084,439,1088,389,1092,394,1096,1100,1104,1108,1112,1117,1118,1121,176,1126,212,1129,1132,1135,1136,176,1139,1142,1146,1149,1150,1153,1154,1157,84,1161,85,1164,1167,1168,1171,1174,1177,1178,1181,1184,1185,212,1187,1190,1193,1196,1197,1200,1203,1204,1207,1208,212,1210,1213,1216,1219,1220,1223,1226],{},">。",[21,320],{"$":321,"style":27},{"html":26,"block":4},"（2）Order命令：通过Allow,Deny参数，Apache首先找到并应用Allow命令，然后应用Deny命令，以阻止所有访问，也可以使用Deny,Allow。",[21,324],{"$":325,"style":27},{"html":26,"block":4},"四、URL重写",[29,328],{"$":329,"style":32},{"html":26,"block":4},[21,331],{"$":332,"style":27},{"html":26,"block":4},"下面是一段简单的URL重写规则示例：",[21,335],{"$":336,"style":27},{"html":26,"block":4},[72,338],{"$":339,"id":340,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut19472",[80,342],{"$":343,"style":83},{"html":26,"block":4},[66,345],{"$":346,"class":69,"style":70},{"html":26,"block":4},"# 将 RewriteEngine 模式打开 ",[80,349],{"$":350,"style":351},{"html":26,"block":4},"font-size: 16px;",[90,353],{"$":354},{"html":26,"block":4},[39,356],{"$":357,"style":32},{"html":26,"block":4},"RewriteEngine On ",[80,360],{"$":361,"style":351},{"html":26,"block":4},[90,363],{"$":364},{"html":26,"block":4},[39,366],{"$":367,"style":32},{"html":26,"block":4},"# Rewrite 系统规则请勿修改 ",[80,370],{"$":371,"style":351},{"html":26,"block":4},[90,373],{"$":374},{"html":26,"block":4},[39,376],{"$":377,"style":32},{"html":26,"block":4},"RewriteRule ^p\u002F(",[80,380,381],{},"0-9","+).htmli",[80,384],{"$":385,"id":386,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-3","mi","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; font-family: MathJax_Math-italic;","n",[80,391],{"$":392,"id":393,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-4","d",[80,396],{"$":397,"id":398,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-5","e",[80,401],{"$":402,"id":403,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-6","x",[80,406],{"$":407,"id":408,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-7",".",[80,411],{"$":412,"id":413,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-8","mo","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; font-family: MathJax_Main;",[80,417],{"$":418,"id":419,"class":387,"style":420},{"html":26,"block":4},"MathJax-Span-9","padding: 0px 0px 0px 0.164em; margin: 0px; transition: none 0s ease 0s; display: inline; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; font-family: MathJax_Math-italic;","h",[80,423],{"$":424,"id":425,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-10",[80,427],{"$":428,"id":429,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-11","?",[80,432],{"$":433,"id":434,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-12",[80,436],{"$":437,"id":438,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-13","o",[80,441],{"$":442,"id":443,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-14","s",[80,446],{"$":447,"id":448,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-15","t",[80,451],{"$":452,"id":453,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-17",[80,455],{"$":456,"style":457},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; position: absolute; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; clip: rect(3.175em, 1000.33em, 4.142em, -999.997em); top: -3.976em; left: 0em;","i",[80,460],{"$":461,"id":462,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-18",[80,464],{"$":465,"style":466},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; position: absolute; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; top: -3.815em; left: 0.379em;",[80,468],{"$":469,"style":470},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 0.702em; height: 0px;",[80,472],{"$":473,"id":474,"class":475,"style":476},{"html":26,"block":4},"MathJax-Span-16","msubsup","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box;",[80,478],{"$":479,"id":480,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-19","=",[80,483],{"$":484,"id":485,"class":414,"style":486},{"html":26,"block":4},"MathJax-Span-20","padding: 0px 0px 0px 0.272em; margin: 0px; transition: none 0s ease 0s; display: inline; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; font-family: MathJax_Main;",[80,488],{"$":489,"id":490,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-2","mrow",[80,493],{"$":494,"style":495},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; position: absolute; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; clip: rect(1.347em, 1008.71em, 2.583em, -999.997em); top: -2.202em; left: 0em;",[80,497],{"$":498,"style":499},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 8.766em; height: 0px;",[80,501],{"$":502,"id":503,"class":504,"style":505},{"html":26,"block":4},"MathJax-Span-1","math","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 10.54em;","index.php?postid=",[80,508],{"$":509,"class":510,"style":511,"role":512},{"html":26,"block":4},"MJX_Assistive_MathML","padding: 0px; margin: 0px; top: 0px; left: 0px; clip: rect(1px, 1px, 1px, 1px); user-select: none; position: static; border: 0px; display: inline; transition: none 0s ease 0s; vertical-align: 0px; line-height: normal; box-sizing: content-box; height: 1px !important; width: 1px !important; overflow: hidden !important;","presentation",[80,514],{"$":515,"id":516,"class":517,"style":518,"tabindex":519,"role":512,"data-mathml":520},{"html":26,"block":4},"MathJax-Element-1-Frame","MathJax","padding: 0px; margin: 0px; display: inline; line-height: normal; word-spacing: normal; overflow-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;","0","\u003Cmath xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML\">\u003Cmi>i\u003C\u002Fmi>\u003Cmi>n\u003C\u002Fmi>\u003Cmi>d\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmi>x\u003C\u002Fmi>\u003Cmo>.\u003C\u002Fmo>\u003Cmi>p\u003C\u002Fmi>\u003Cmi>h\u003C\u002Fmi>\u003Cmi>p\u003C\u002Fmi>\u003Cmo>?\u003C\u002Fmo>\u003Cmi>p\u003C\u002Fmi>\u003Cmi>o\u003C\u002Fmi>\u003Cmi>s\u003C\u002Fmi>\u003Cmsub>\u003Cmi>t\u003C\u002Fmi>\u003Cmi>i\u003C\u002Fmi>\u003C\u002Fmsub>\u003Cmi>d\u003C\u002Fmi>\u003Cmo>=\u003C\u002Fmo>\u003C\u002Fmath>","1",[80,523],{"$":524,"style":351},{"html":26,"block":4},[90,526],{"$":527},{"html":26,"block":4},[39,529],{"$":530,"style":32},{"html":26,"block":4},"RewriteRule ^u-(username|uid)-(.+).htmls",[80,533],{"$":534,"id":535,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-23",[80,537],{"$":538,"id":539,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-24",[80,541],{"$":542,"id":543,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-25","c",[80,546],{"$":547,"id":548,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-26",[80,550],{"$":551,"id":552,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-27",[80,554],{"$":555,"id":556,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-28",[80,558],{"$":559,"id":560,"class":387,"style":420},{"html":26,"block":4},"MathJax-Span-29",[80,562],{"$":563,"id":564,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-30",[80,566],{"$":567,"id":568,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-31",[80,570],{"$":571,"id":572,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-32",[80,574],{"$":575,"id":576,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-22",[80,578],{"$":579,"style":580},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; position: absolute; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; clip: rect(1.347em, 1004.84em, 2.583em, -999.997em); top: -2.202em; left: 0em;",[80,582],{"$":583,"style":584},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 4.895em; height: 0px;",[80,586],{"$":587,"id":588,"class":504,"style":589},{"html":26,"block":4},"MathJax-Span-21","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 5.863em;","space.php?",[80,592],{"$":593,"class":510,"style":511,"role":512},{"html":26,"block":4},[80,595],{"$":596,"id":597,"class":517,"style":518,"tabindex":519,"role":512,"data-mathml":598},{"html":26,"block":4},"MathJax-Element-2-Frame","\u003Cmath xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML\">\u003Cmi>s\u003C\u002Fmi>\u003Cmi>p\u003C\u002Fmi>\u003Cmi>a\u003C\u002Fmi>\u003Cmi>c\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmo>.\u003C\u002Fmo>\u003Cmi>p\u003C\u002Fmi>\u003Cmi>h\u003C\u002Fmi>\u003Cmi>p\u003C\u002Fmi>\u003Cmo>?\u003C\u002Fmo>\u003C\u002Fmath>","1=$2",[80,601],{"$":602,"style":351},{"html":26,"block":4},[90,604],{"$":605},{"html":26,"block":4},[66,607],{"$":608,"class":69,"style":70},{"html":26,"block":4},[39,610],{"$":611,"style":32},{"html":26,"block":4},"其中，RewriteEngine 表示开启URL重写，RewriteRule是重写规则。",[21,614],{"$":615,"style":27},{"html":26,"block":4},[21,617],{"$":618,"style":27},{"html":26,"block":4},"五、配置错误页面",[29,621],{"$":622,"style":32},{"html":26,"block":4},[21,624],{"$":625,"style":27},{"html":26,"block":4},"基本语法如下：",[21,628],{"$":629,"style":27},{"html":26,"block":4},[72,631],{"$":632,"id":633,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut910",[80,635],{"$":636,"style":83},{"html":26,"block":4},[66,638],{"$":639,"class":69,"style":70},{"html":26,"block":4},"# custom error documents",[90,642],{"$":643},{"html":26,"block":4},[39,645],{"$":646,"style":32},{"html":26,"block":4},"ErrorDocument 401 \u002Ferr\u002F401.php",[90,649],{"$":650},{"html":26,"block":4},[39,652],{"$":653,"style":32},{"html":26,"block":4},"ErrorDocument 403 \u002Ferr\u002F403.php",[90,656],{"$":657},{"html":26,"block":4},[39,659],{"$":660,"style":32},{"html":26,"block":4},"ErrorDocument 404 \u002Ferr\u002F404.php",[90,663],{"$":664},{"html":26,"block":4},[39,666],{"$":667,"style":32},{"html":26,"block":4},"ErrorDocument 500 \u002Ferr\u002F500.php",[90,670],{"$":671},{"html":26,"block":4},[66,673],{"$":674,"class":69,"style":70},{"html":26,"block":4},[21,676],{"$":677,"style":27},{"html":26,"block":4},"六、htaccess常用命令和配置技巧",[39,680],{"$":681,"style":32},{"html":26,"block":4},[29,683],{"$":684,"style":32},{"html":26,"block":4},"1.禁止显示目录列表",[39,687],{"$":688,"style":32},{"html":26,"block":4},"有些时候，由于某种原因，你的目录里没有index文件，这意味着当有人在浏览器地址栏键入了该目录的路径，该目录下所有的文件都会显示出来，这会给你的网站留下安全隐患。",[39,691],{"$":692,"style":32},{"html":26,"block":4},"为避免这种情况（而不必创建一堆的新index文件），你可以在你的.htaccess文档中键入以下命令，用以阻止",[39,695],{"$":696,"style":32},{"html":26,"block":4},"目录列表的显示：",[21,699],{"$":700,"style":27},{"html":26,"block":4},[72,702],{"$":703,"id":704,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut83156",[80,706],{"$":707,"style":83},{"html":26,"block":4},[66,709],{"$":710,"class":69,"style":70},{"html":26,"block":4},"Options -Indexes",[90,713],{"$":714},{"html":26,"block":4},[66,716],{"$":717,"id":718,"class":168,"style":70},{"html":26,"block":4},"code83156",[39,720],{"$":721,"style":32},{"html":26,"block":4},"2.阻止\u002F允许特定的IP地址",[39,724],{"$":725,"style":32},{"html":26,"block":4},"某些情况下，你可能只想允许某些特定IP的用户可以访问你的网站（例如：只允许使用特定ISP的用户进入某个目录），或者想封禁某些特定的IP地址（例如：将低级用户隔离于你的信息版面外）。当然，这只在你知道你想拦截的IP地址时才有用，然而现在网上的大多数用户都使用动态IP地址，所以这并不是限制使用的常用方法。",[39,728],{"$":729,"style":32},{"html":26,"block":4},"你可以使用以下命令封禁一个IP地址：",[21,732],{"$":733,"style":27},{"html":26,"block":4},[72,735],{"$":736,"id":737,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut9859",[80,739],{"$":740,"style":83},{"html":26,"block":4},[66,742],{"$":743,"class":69,"style":70},{"html":26,"block":4},"deny from 000.000.000.000",[90,746],{"$":747},{"html":26,"block":4},[66,749],{"$":750,"id":751,"class":168,"style":70},{"html":26,"block":4},"code9859",[39,753],{"$":754,"style":32},{"html":26,"block":4},"这里的000.000.000.000是被封禁的IP地址，如果你只指明了其中的几个，则可以封禁整个网段的地址。如你输入210.10.56.，则将封禁210.10.56.0～210.10.56.255的所有IP地址。",[39,757],{"$":758,"style":32},{"html":26,"block":4},"你可以使用以下命令允许一个IP地址访问网站：",[21,761],{"$":762,"style":27},{"html":26,"block":4},[72,764],{"$":765,"id":766,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut29749",[80,768],{"$":769,"style":83},{"html":26,"block":4},[66,771],{"$":772,"class":69,"style":70},{"html":26,"block":4},"allow from 000.000.000.000",[90,775],{"$":776},{"html":26,"block":4},[66,778],{"$":779,"id":780,"class":168,"style":70},{"html":26,"block":4},"code29749",[39,782],{"$":783,"style":32},{"html":26,"block":4},"被允许的IP地址则为000.000.000.000，你可以象封禁IP地址一样允许整个网段。",[39,786],{"$":787,"style":32},{"html":26,"block":4},"如果你想阻止所有人访问该目录，则可以使用：",[21,790],{"$":791,"style":27},{"html":26,"block":4},[72,793],{"$":794,"id":795,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut96637",[80,797],{"$":798,"style":83},{"html":26,"block":4},[66,800],{"$":801,"class":69,"style":70},{"html":26,"block":4},"deny from all",[90,804],{"$":805},{"html":26,"block":4},[66,807],{"$":808,"id":809,"class":168,"style":70},{"html":26,"block":4},"code96637",[39,811],{"$":812,"style":32},{"html":26,"block":4},"不过这并不影响脚本程序使用这个目录下的文档。",[39,815],{"$":816,"style":32},{"html":26,"block":4},"3.替换index文件",[39,819],{"$":820,"style":32},{"html":26,"block":4},"也许你不想一直使用index.htm或index.html作为目录的索引文件。举例来说，如果你的站点使用PHP文件，你可能会想使用 index.php来作为该目录的索引文档。当然也不必局限于“index”文档，如果你愿意，使用.htaccess你甚至能够设置 foofoo.balh来作为你的索引文档！",[39,823],{"$":824,"style":32},{"html":26,"block":4},"这些互为替换的索引文件可以排成一个列表，服务器会从左至右进行寻找，检查哪个文档在真实的目录中存在。如果一个也找不到，它将会把目录列表显示出来（除非你已经关闭了显示目录文件列表）。",[21,827],{"$":828,"style":27},{"html":26,"block":4},[72,830],{"$":831,"id":832,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut95973",[80,834],{"$":835,"style":83},{"html":26,"block":4},[66,837],{"$":838,"class":69,"style":70},{"html":26,"block":4},"DirectoryIndex index.php index.php3 ",[72,841,843],{"href":842},"http:\u002F\u002Fmessagebrd.pl","messagebrd.pl"," index.html index.htm",[90,846],{"$":847},{"html":26,"block":4},[66,849],{"$":850,"id":851,"class":168,"style":70},{"html":26,"block":4},"code95973",[39,853],{"$":854,"style":32},{"html":26,"block":4},"4.重定向(rewrite)",[39,857],{"$":858,"style":32},{"html":26,"block":4},".htaccess 最有用的功能之一就是将请求重定向到同站内或站外的不同文档。这在你改变了一个文件名称，但仍然想让用户用旧地址访问到它时，变的极为有用。另一个应用（我发现的很有用的）是重定向到一个长URL，例如在我的时事通讯中，我可以使用一个很简短的URL来指向我的会员链接。以下是一个重定向文件的例子：",[21,861],{"$":862,"style":27},{"html":26,"block":4},[72,864],{"$":865,"id":866,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut71406",[80,868],{"$":869,"style":83},{"html":26,"block":4},[66,871],{"$":872,"class":69,"style":70},{"html":26,"block":4},"Redirect \u002Flocation\u002Ffrom\u002Froot\u002Ffile.ext http:\u002F\u002F\u002Fnew\u002Ffile\u002Flocation.xyz",[90,875],{"$":876},{"html":26,"block":4},[66,878],{"$":879,"id":880,"class":168,"style":70},{"html":26,"block":4},"code71406",[39,882],{"$":883,"style":32},{"html":26,"block":4},"上述例子中，访问在root目录下的名为oldfile.html可以键入：",[21,886],{"$":887,"style":27},{"html":26,"block":4},[72,889],{"$":890,"id":891,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut45108",[80,893],{"$":894,"style":83},{"html":26,"block":4},[66,896],{"$":897,"class":69,"style":70},{"html":26,"block":4},"\u002Foldfile.html",[90,900],{"$":901},{"html":26,"block":4},[66,903],{"$":904,"id":905,"class":168,"style":70},{"html":26,"block":4},"code45108",[39,907],{"$":908,"style":32},{"html":26,"block":4},"访问一个旧次级目录中的文件可以键入：",[21,911],{"$":912,"style":27},{"html":26,"block":4},[72,914],{"$":915,"id":916,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut97446",[80,918],{"$":919,"style":83},{"html":26,"block":4},[66,921],{"$":922,"class":69,"style":70},{"html":26,"block":4},"\u002Fold\u002Foldfile.html",[90,925],{"$":926},{"html":26,"block":4},[66,928],{"$":929,"id":930,"class":168,"style":70},{"html":26,"block":4},"code97446",[39,932],{"$":933,"style":32},{"html":26,"block":4},"你也可以使用.htaccess重定向整个网站的目录。假如你的网站上有一个名为olddirectory的目录，并且你已经在一个新网站http: \u002F\u002F\u002Fnewdirectory\u002F上建立了与上相同的文档，你可以将旧目录下所有的文件做一次重定向而不必一一声明：",[21,936],{"$":937,"style":27},{"html":26,"block":4},[72,939],{"$":940,"id":941,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut40431",[80,943],{"$":944,"style":83},{"html":26,"block":4},[66,946],{"$":947,"class":69,"style":70},{"html":26,"block":4},"Redirect \u002Folddirectory http:　\u002F\u002F\u002Fnewdirectory",[90,950],{"$":951},{"html":26,"block":4},[66,953],{"$":954,"id":955,"class":168,"style":70},{"html":26,"block":4},"code40431",[39,957],{"$":958,"style":32},{"html":26,"block":4},"这样，任何指向到站点中\u002Folddirectory目录的请求都将被重新指向新的站点，包括附加的额外URL信息。例如有人键入：",[21,961],{"$":962,"style":27},{"html":26,"block":4},[72,964],{"$":965,"id":966,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut64593",[80,968],{"$":969,"style":83},{"html":26,"block":4},[66,971],{"$":972,"class":69,"style":70},{"html":26,"block":4},"http: \u002F\u002F\u002Folddirecotry\u002Foldfiles\u002Fimages\u002Fimage.gif",[90,975],{"$":976},{"html":26,"block":4},[66,978],{"$":979,"id":980,"class":168,"style":70},{"html":26,"block":4},"code64593",[39,982],{"$":983,"style":32},{"html":26,"block":4},"请求将被重定向到：",[21,986],{"$":987,"style":27},{"html":26,"block":4},[72,989],{"$":990,"id":991,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut92105",[80,993],{"$":994,"style":83},{"html":26,"block":4},[66,996],{"$":997,"class":69,"style":70},{"html":26,"block":4},"http: \u002F\u002F\u002Fnewdirectory\u002Foldfiles\u002Fimages\u002Fimage.gif",[90,1000],{"$":1001},{"html":26,"block":4},[66,1003],{"$":1004,"id":1005,"class":168,"style":70},{"html":26,"block":4},"code92105",[39,1007],{"$":1008,"style":32},{"html":26,"block":4},"如果正确使用，此功能将极其强大。",[21,1011],{"$":1012,"style":27},{"html":26,"block":4},[21,1014],{"$":1015,"style":27},{"html":26,"block":4},"七、安全配置",[39,1018],{"$":1019,"style":32},{"html":26,"block":4},[29,1021],{"$":1022,"style":32},{"html":26,"block":4},"下面的htaccess代码能够提高你的web服务器的安全水平。图片链接盗用保护非常有用，它能防止其他人偷盗使用你的服务器上的图片资源。",[39,1025],{"$":1026,"style":32},{"html":26,"block":4},"1. 通过.htaccess放盗链",[39,1029],{"$":1030,"style":32},{"html":26,"block":4},"痛恨那些偷盗链接你的web服务器上的图片资源而耗尽了你的带宽的行为吗？试试这个，你可以防止这种事情的发生。",[21,1033],{"$":1034,"style":27},{"html":26,"block":4},[72,1036],{"$":1037,"id":1038,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut56453",[80,1040],{"$":1041,"style":83},{"html":26,"block":4},[66,1043],{"$":1044,"class":69,"style":70},{"html":26,"block":4},"RewriteBase \u002F  ",[90,1047],{"$":1048},{"html":26,"block":4},[39,1050],{"$":1051,"style":32},{"html":26,"block":4},"RewriteCond % !^R",[80,1054],{"$":1055,"id":1056,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-35",[80,1058],{"$":1059,"id":1060,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-36","w",[80,1063],{"$":1064,"id":1065,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-37","r",[80,1068],{"$":1069,"id":1070,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-38",[80,1072],{"$":1073,"id":1074,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-39",[80,1076],{"$":1077,"id":1078,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-40",[80,1080],{"$":1081,"id":1082,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-41","C",[80,1085],{"$":1086,"id":1087,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-42",[80,1089],{"$":1090,"id":1091,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-43",[80,1093],{"$":1094,"id":1095,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-44",[80,1097],{"$":1098,"id":1099,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-45",[80,1101],{"$":1102,"id":1103,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-34",[80,1105],{"$":1106,"style":1107},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; position: absolute; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; clip: rect(1.293em, 1005.97em, 2.315em, -999.997em); top: -2.148em; left: 0em;",[80,1109],{"$":1110,"style":1111},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 5.97em; height: 0px; font-size: 18.6px;",[80,1113],{"$":1114,"id":1115,"class":504,"style":1116},{"html":26,"block":4},"MathJax-Span-33","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 7.207em;","RewriteCond",[80,1119],{"$":1120,"class":510,"style":511,"role":512},{"html":26,"block":4},[80,1122],{"$":1123,"id":1124,"class":517,"style":518,"tabindex":519,"role":512,"data-mathml":1125},{"html":26,"block":4},"MathJax-Element-3-Frame","\u003Cmath xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML\">\u003Cmi>R\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmi>w\u003C\u002Fmi>\u003Cmi>r\u003C\u002Fmi>\u003Cmi>i\u003C\u002Fmi>\u003Cmi>t\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmi>C\u003C\u002Fmi>\u003Cmi>o\u003C\u002Fmi>\u003Cmi>n\u003C\u002Fmi>\u003Cmi>d\u003C\u002Fmi>\u003C\u002Fmath>",[80,1127,1128],{},"NC",[90,1130],{"$":1131},{"html":26,"block":4},[39,1133],{"$":1134,"style":32},{"html":26,"block":4},"RewriteRule .(gif|jpg|swf|flv|png)$ \u002Ffeed\u002F ",[80,1137,1138],{},"R=302,L",[90,1140],{"$":1141},{"html":26,"block":4},[66,1143],{"$":1144,"id":1145,"class":168,"style":70},{"html":26,"block":4},"code56453",[39,1147],{"$":1148,"style":32},{"html":26,"block":4},"2. 防黑客",[39,1151],{"$":1152,"style":32},{"html":26,"block":4},"如果你想提高网站的安全等级，你可以去掉下面的几行代码，这样可以防止一些常见恶意URL匹配的黑客攻击技术。",[21,1155],{"$":1156,"style":27},{"html":26,"block":4},[72,1158],{"$":1159,"id":1160,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut89969",[80,1162],{"$":1163,"style":83},{"html":26,"block":4},[66,1165],{"$":1166,"class":69,"style":70},{"html":26,"block":4},"RewriteEngine On  ",[90,1169],{"$":1170},{"html":26,"block":4},[39,1172],{"$":1173,"style":32},{"html":26,"block":4},[39,1175],{"$":1176,"style":32},{"html":26,"block":4},"# proc\u002Fself\u002Fenviron? 没门！  ",[90,1179],{"$":1180},{"html":26,"block":4},[39,1182],{"$":1183,"style":32},{"html":26,"block":4},"RewriteCond % proc\u002Fself\u002Fenviron ",[80,1186,211],{},[90,1188],{"$":1189},{"html":26,"block":4},[39,1191],{"$":1192,"style":32},{"html":26,"block":4},[39,1194],{"$":1195,"style":32},{"html":26,"block":4},"# 阻止脚本企图通过URL修改mosConfig值  ",[90,1198],{"$":1199},{"html":26,"block":4},[39,1201],{"$":1202,"style":32},{"html":26,"block":4},"RewriteCond % mosConfig_",[80,1205,1206],{},"a-zA-Z_","(=|%3D) ",[80,1209,211],{},[90,1211],{"$":1212},{"html":26,"block":4},[39,1214],{"$":1215,"style":32},{"html":26,"block":4},[39,1217],{"$":1218,"style":32},{"html":26,"block":4},"# 阻止脚本通过URL传递的base64_encode垃圾信息  ",[90,1221],{"$":1222},{"html":26,"block":4},[39,1224],{"$":1225,"style":32},{"html":26,"block":4},"RewriteCond % base64_encode.","(.",[80,1229,211],{},[39,1231],{"$":1232,"style":32},{"html":26,"block":4},[39,1234],{"$":1235,"style":32},{"html":26,"block":4},[90,1237,1239],{"$":1238},{"html":26,"block":4},"# 阻止在URL含有\u003Cscript>标记的脚本  ",[39,1241],{"$":1242,"style":32},{"html":26,"block":4},[90,1244,216,1246,1247,1250,1251,212],{"$":1245},{"html":26,"block":4}," (\u003C|%3C).",[256,1248,1249],{},"script.","(>|%3E) ",[80,1252,1253],{},"NC,OR",[39,1255],{"$":1256,"style":32},{"html":26,"block":4},[39,1258],{"$":1259,"style":32},{"html":26,"block":4},[90,1261,1263],{"$":1262},{"html":26,"block":4},"# 阻止企图通过URL设置PHP的GLOBALS变量的脚本  ",[39,1265],{"$":1266,"style":32},{"html":26,"block":4},[39,1268],{"$":1269,"style":32},{"html":26,"block":4},"3. 阻止访问你的 .htaccess 文件或者指定类型的文件",[39,1272],{"$":1273,"style":32},{"html":26,"block":4},"下面的代码可以阻止别人访问你的.htaccess文件。同样，你也可以设定阻止多种文件类型。",[39,1276],{"$":1277,"style":32},{"html":26,"block":4},"# 保护你的 htaccess 文件  ",[90,1280],{"$":1281},{"html":26,"block":4},[39,1283],{"$":1284,"style":32},{"html":26,"block":4},"\u003CFiles .htaccess>  ",[90,1287],{"$":1288},{"html":26,"block":4},[39,1290],{"$":1291,"style":32},{"html":26,"block":4},"order allow,deny  ",[90,1294],{"$":1295},{"html":26,"block":4},[39,1297],{"$":1298,"style":32},{"html":26,"block":4},"deny from all  ",[90,1301],{"$":1302},{"html":26,"block":4},[39,1304],{"$":1305,"style":32},{"html":26,"block":4},"\u003C\u002FFiles>  ",[90,1308],{"$":1309},{"html":26,"block":4},[39,1311],{"$":1312,"style":32},{"html":26,"block":4},[39,1314],{"$":1315,"style":32},{"html":26,"block":4},"# 阻止查看指定的文件  ",[90,1318],{"$":1319},{"html":26,"block":4},[39,1321],{"$":1322,"style":32},{"html":26,"block":4},"\u003CFiles secretfile.jpg>  ",[90,1325],{"$":1326},{"html":26,"block":4},[39,1328],{"$":1329,"style":32},{"html":26,"block":4},[90,1331],{"$":1332},{"html":26,"block":4},[39,1334],{"$":1335,"style":32},{"html":26,"block":4},[90,1337],{"$":1338},{"html":26,"block":4},[39,1340],{"$":1341,"style":32},{"html":26,"block":4},[90,1343],{"$":1344},{"html":26,"block":4},[39,1346],{"$":1347,"style":32},{"html":26,"block":4},[39,1349],{"$":1350,"style":32},{"html":26,"block":4},"# 多种文件类型  ",[90,1353],{"$":1354},{"html":26,"block":4},[39,1356],{"$":1357,"style":32},{"html":26,"block":4},"\u003CFilesMatch “.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$”>  ",[90,1360],{"$":1361},{"html":26,"block":4},[39,1363],{"$":1364,"style":32},{"html":26,"block":4}," Order Allow,Deny  ",[90,1367],{"$":1368},{"html":26,"block":4},[39,1370],{"$":1371,"style":32},{"html":26,"block":4},"Deny from all  ",[90,1374],{"$":1375},{"html":26,"block":4},[39,1377],{"$":1378,"style":32},{"html":26,"block":4},"\u003C\u002FFilesMatch>[\u002Fcode] ",[90,1381],{"$":1382},{"html":26,"block":4},[39,1384],{"$":1385,"style":32},{"html":26,"block":4},"4.禁止脚本执行，加强你的目录安全",[21,1388],{"$":1389,"style":27},{"html":26,"block":4},[72,1391],{"$":1392,"id":1393,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut62861",[80,1395],{"$":1396,"style":83},{"html":26,"block":4},[66,1398],{"$":1399,"class":69,"style":70},{"html":26,"block":4},"# 禁止某些目录里的脚本执行权限  ",[90,1402],{"$":1403},{"html":26,"block":4},[39,1405],{"$":1406,"style":32},{"html":26,"block":4},"AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi  ",[90,1409],{"$":1410},{"html":26,"block":4},[39,1412],{"$":1413,"style":32},{"html":26,"block":4},"Options -ExecCGI",[90,1416],{"$":1417},{"html":26,"block":4},[66,1419],{"$":1420,"id":1421,"class":168,"style":70},{"html":26,"block":4},"code62861",[21,1423],{"$":1424,"style":27},{"html":26,"block":4},[39,1426],{"$":1427,"style":32},{"html":26,"block":4},"八、一些常用的设置",[39,1430],{"$":1431,"style":32},{"html":26,"block":4},[29,1433],{"$":1434,"style":32},{"html":26,"block":4},"1.时区设置",[39,1437],{"$":1438,"style":32},{"html":26,"block":4},"有些时候，当你在PHP里使用date或mktime函数时，由于时区的不同，它会显示出一些很奇怪的信息。下面是解决这个问题的方法之一。就是设置你的服务器的时区。你可以在这里找到所有支持的时区的清单。",[39,1441],{"$":1442,"style":32},{"html":26,"block":4},"1.SetEnv TZ Australia\u002FMelbourne ",[39,1445],{"$":1446,"style":32},{"html":26,"block":4},"2. seo\u002Fseo.html\" target=\"_blank\">搜索引擎友好的301永久转向方法",[39,1449],{"$":1450,"style":32},{"html":26,"block":4},"为什么这是搜索引擎友好的呢？因为现在很多现代的搜索引擎都有能根据检查301永久转向来更新它现有的记录的功能。",[21,1453],{"$":1454,"style":27},{"html":26,"block":4},[72,1456],{"$":1457,"id":1458,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut70743",[80,1460],{"$":1461,"style":83},{"html":26,"block":4},[66,1463],{"$":1464,"class":69,"style":70},{"html":26,"block":4},"Redirect 301 http:\u002F\u002Fwww.aqee.net\u002Fhome http:\u002F\u002Fwww.aqee.net\u002F ",[90,1467],{"$":1468},{"html":26,"block":4},[66,1470],{"$":1471,"id":1472,"class":168,"style":70},{"html":26,"block":4},"code70743",[39,1474],{"$":1475,"style":32},{"html":26,"block":4},"3. 屏蔽下载对话框",[39,1478],{"$":1479,"style":32},{"html":26,"block":4},"通常，当你下载东西的时候，你会看到一个对话框询问你是保持这个文件还是直接打开它。如果你不想看到这个东西，你可以把下面的一段代码放到你的.htaccess文件里。",[21,1482],{"$":1483,"style":27},{"html":26,"block":4},[72,1485],{"$":1486,"id":1487,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut20541",[80,1489],{"$":1490,"style":83},{"html":26,"block":4},[66,1492],{"$":1493,"class":69,"style":70},{"html":26,"block":4},"AddType application\u002Foctet-stream .pdf  ",[90,1496],{"$":1497},{"html":26,"block":4},[39,1499],{"$":1500,"style":32},{"html":26,"block":4},"AddType application\u002Foctet-stream .zip  ",[90,1503],{"$":1504},{"html":26,"block":4},[39,1506],{"$":1507,"style":32},{"html":26,"block":4},"AddType application\u002Foctet-stream .mov ",[90,1510],{"$":1511},{"html":26,"block":4},[66,1513],{"$":1514,"id":1515,"class":168,"style":70},{"html":26,"block":4},"code20541",[39,1517],{"$":1518,"style":32},{"html":26,"block":4},"4. 省去www前缀",[39,1521],{"$":1522,"style":32},{"html":26,"block":4},"SEO的一个原则是，确保你的网站只有一个URL。因此，你需要把所有的通过www的访问转向的非www，或者反这来。",[21,1525],{"$":1526,"style":27},{"html":26,"block":4},[72,1528],{"$":1529,"id":1530,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut97705",[80,1532],{"$":1533,"style":83},{"html":26,"block":4},[66,1535],{"$":1536,"class":69,"style":70},{"html":26,"block":4},[90,1538],{"$":1539},{"html":26,"block":4},[39,1541],{"$":1542,"style":32},{"html":26,"block":4},[90,1544],{"$":1545},{"html":26,"block":4},[39,1547],{"$":1548,"style":32},{"html":26,"block":4},"RewriteCond % ^www.aqee.net [NC]  ",[90,1551],{"$":1552},{"html":26,"block":4},[39,1554],{"$":1555,"style":32},{"html":26,"block":4},")h",[80,1558],{"$":1559,"id":1560,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-48",[80,1562],{"$":1563,"id":1564,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-49",[80,1566],{"$":1567,"id":1568,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-50",[80,1570],{"$":1571,"id":1572,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-51",":",[80,1575],{"$":1576,"id":1577,"class":414,"style":486},{"html":26,"block":4},"MathJax-Span-52","\u002F",[80,1580],{"$":1581,"id":1582,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-55",[80,1584],{"$":1585,"id":1586,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-54",[80,1588],{"$":1589,"id":1590,"class":1591,"style":1592},{"html":26,"block":4},"MathJax-Span-53","texatom","padding: 0px 0px 0px 0.272em; margin: 0px; transition: none 0s ease 0s; display: inline; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box;",[80,1594],{"$":1595,"id":1596,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-58",[80,1598],{"$":1599,"id":1600,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-57",[80,1602],{"$":1603,"id":1604,"class":1591,"style":476},{"html":26,"block":4},"MathJax-Span-56",[80,1606],{"$":1607,"id":1608,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-59","q",[80,1611],{"$":1612,"id":1613,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-60",[80,1615],{"$":1616,"id":1617,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-61",[80,1619],{"$":1620,"id":1621,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-62",[80,1623],{"$":1624,"id":1625,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-63",[80,1627],{"$":1628,"id":1629,"class":387,"style":420},{"html":26,"block":4},"MathJax-Span-64",[80,1631],{"$":1632,"id":1633,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-65",[80,1635],{"$":1636,"id":1637,"class":387,"style":388},{"html":26,"block":4},"MathJax-Span-66",[80,1639],{"$":1640,"id":1641,"class":414,"style":415},{"html":26,"block":4},"MathJax-Span-69",[80,1643],{"$":1644,"id":1645,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-68",[80,1647],{"$":1648,"id":1649,"class":1591,"style":476},{"html":26,"block":4},"MathJax-Span-67",[80,1651],{"$":1652,"id":1653,"class":491,"style":476},{"html":26,"block":4},"MathJax-Span-47",[80,1655],{"$":1656,"style":1657},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; position: absolute; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; clip: rect(1.293em, 1007.85em, 2.637em, -999.997em); top: -2.202em; left: 0em;",[80,1659],{"$":1660,"style":1661},{"html":26,"block":4},"padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: relative; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 7.906em; height: 0px; font-size: 18.6px;",[80,1663],{"$":1664,"id":1665,"class":504,"style":1666},{"html":26,"block":4},"MathJax-Span-46","padding: 0px; margin: 0px; transition: none 0s ease 0s; display: inline-block; position: static; border: 0px; vertical-align: 0px; line-height: normal; box-sizing: content-box; width: 9.519em;","http:\u002F\u002Faqee.net\u002F",[80,1669],{"$":1670,"class":510,"style":511,"role":512},{"html":26,"block":4},[80,1672],{"$":1673,"id":1674,"class":517,"style":518,"tabindex":519,"role":512,"data-mathml":1675},{"html":26,"block":4},"MathJax-Element-4-Frame","\u003Cmath xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1998\u002FMath\u002FMathML\">\u003Cmi>h\u003C\u002Fmi>\u003Cmi>t\u003C\u002Fmi>\u003Cmi>t\u003C\u002Fmi>\u003Cmi>p\u003C\u002Fmi>\u003Cmo>:\u003C\u002Fmo>\u003Cmrow class=\"MJX-TeXAtom-ORD\">\u003Cmo>\u002F\u003C\u002Fmo>\u003C\u002Fmrow>\u003Cmrow class=\"MJX-TeXAtom-ORD\">\u003Cmo>\u002F\u003C\u002Fmo>\u003C\u002Fmrow>\u003Cmi>a\u003C\u002Fmi>\u003Cmi>q\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmo>.\u003C\u002Fmo>\u003Cmi>n\u003C\u002Fmi>\u003Cmi>e\u003C\u002Fmi>\u003Cmi>t\u003C\u002Fmi>\u003Cmrow class=\"MJX-TeXAtom-ORD\">\u003Cmo>\u002F\u003C\u002Fmo>\u003C\u002Fmrow>\u003C\u002Fmath>","1 [L,R=301]",[90,1678],{"$":1679},{"html":26,"block":4},[66,1681],{"$":1682,"id":1683,"class":168,"style":70},{"html":26,"block":4},"code97705",[39,1685],{"$":1686,"style":32},{"html":26,"block":4},"5. 个性化Error页面",[39,1689],{"$":1690,"style":32},{"html":26,"block":4},"对每个错误代码定制自己个性化的错误页面。",[21,1693],{"$":1694,"style":27},{"html":26,"block":4},[72,1696],{"$":1697,"id":1698,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut92769",[80,1700],{"$":1701,"style":83},{"html":26,"block":4},[66,1703],{"$":1704,"class":69,"style":70},{"html":26,"block":4},"ErrorDocument 401 \u002Ferror\u002F401.php  ",[90,1707],{"$":1708},{"html":26,"block":4},[39,1710],{"$":1711,"style":32},{"html":26,"block":4},"ErrorDocument 403 \u002Ferror\u002F403.php  ",[90,1714],{"$":1715},{"html":26,"block":4},[39,1717],{"$":1718,"style":32},{"html":26,"block":4},"ErrorDocument 404 \u002Ferror\u002F404.php  ",[90,1721],{"$":1722},{"html":26,"block":4},[39,1724],{"$":1725,"style":32},{"html":26,"block":4},"ErrorDocument 500 \u002Ferror\u002F500.php",[90,1728],{"$":1729},{"html":26,"block":4},[66,1731],{"$":1732,"id":1733,"class":168,"style":70},{"html":26,"block":4},"code92769",[39,1735],{"$":1736,"style":32},{"html":26,"block":4},"6. 压缩文件",[39,1739],{"$":1740,"style":32},{"html":26,"block":4},"通过压缩你的文件体积来优化网站的访问速度。",[21,1743],{"$":1744,"style":27},{"html":26,"block":4},[72,1746],{"$":1747,"id":1748,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut81020",[80,1750],{"$":1751,"style":83},{"html":26,"block":4},[66,1753],{"$":1754,"class":69,"style":70},{"html":26,"block":4},"# 压缩 text, html, javascript, css, xml:  ",[90,1757],{"$":1758},{"html":26,"block":4},[39,1760],{"$":1761,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE text\u002Fplain  ",[90,1764],{"$":1765},{"html":26,"block":4},[39,1767],{"$":1768,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE text\u002Fhtml  ",[90,1771],{"$":1772},{"html":26,"block":4},[39,1774],{"$":1775,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE text\u002Fxml  ",[90,1778],{"$":1779},{"html":26,"block":4},[39,1781],{"$":1782,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE text\u002Fcss  ",[90,1785],{"$":1786},{"html":26,"block":4},[39,1788],{"$":1789,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE application\u002Fxml  ",[90,1792],{"$":1793},{"html":26,"block":4},[39,1795],{"$":1796,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE application\u002Fxhtml+xml  ",[90,1799],{"$":1800},{"html":26,"block":4},[39,1802],{"$":1803,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE application\u002Frss+xml  ",[90,1806],{"$":1807},{"html":26,"block":4},[39,1809],{"$":1810,"style":32},{"html":26,"block":4},"AddOutputFilterByType DEFLATE application\u002Fjavascript  ",[90,1813],{"$":1814},{"html":26,"block":4},[39,1816],{"$":1817,"style":32},{"html":26,"block":4},".AddOutputFilterByType DEFLATE application\u002Fx-javascript ",[90,1820],{"$":1821},{"html":26,"block":4},[66,1823],{"$":1824,"id":1825,"class":168,"style":70},{"html":26,"block":4},"code81020",[39,1827],{"$":1828,"style":32},{"html":26,"block":4},"7. 缓存文件",[39,1831],{"$":1832,"style":32},{"html":26,"block":4},"缓存文件是另外一个提高你的网站访问速度的好方法。",[21,1835],{"$":1836,"style":27},{"html":26,"block":4},[72,1838],{"$":1839,"id":1840,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut16268",[80,1842],{"$":1843,"style":83},{"html":26,"block":4},[66,1845],{"$":1846,"class":69,"style":70},{"html":26,"block":4},"\u003CFilesMatch “.(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$”>  ",[90,1849],{"$":1850},{"html":26,"block":4},[39,1852],{"$":1853,"style":32},{"html":26,"block":4},"Header set Cache-Control “max-age=2592000″  ",[90,1856],{"$":1857},{"html":26,"block":4},[39,1859],{"$":1860,"style":32},{"html":26,"block":4},"\u003C\u002FFilesMatch> ",[90,1863],{"$":1864},{"html":26,"block":4},[66,1866],{"$":1867,"id":1868,"class":168,"style":70},{"html":26,"block":4},"code16268",[39,1870],{"$":1871,"style":32},{"html":26,"block":4},"8. 对某些文件类型禁止使用缓存",[39,1874],{"$":1875,"style":32},{"html":26,"block":4},"而另一方面，你也可以定制对某些文件类型禁止使用缓存。",[21,1878],{"$":1879,"style":27},{"html":26,"block":4},[72,1881],{"$":1882,"id":1883,"class":76,"style":77,"rel":78},{"html":26,"block":4},"copybut10523",[80,1885],{"$":1886,"style":83},{"html":26,"block":4},[66,1888],{"$":1889,"class":69,"style":70},{"html":26,"block":4},"# 显式的规定对脚本和其它动态文件禁止使用缓存  ",[90,1892],{"$":1893},{"html":26,"block":4},[39,1895],{"$":1896,"style":32},{"html":26,"block":4},"\u003CFilesMatch “.(pl|php|cgi|spl|scgi|fcgi)$”>  ",[90,1899],{"$":1900},{"html":26,"block":4},[39,1902],{"$":1903,"style":32},{"html":26,"block":4},"Header unset Cache-Control  ",[90,1906],{"$":1907},{"html":26,"block":4},[39,1909],{"$":1910,"style":32},{"html":26,"block":4},[90,1912],{"$":1913},{"html":26,"block":4},[66,1915],{"$":1916,"id":1917,"class":168,"style":70},{"html":26,"block":4},"code10523",[39,1919],{"$":1920},{"html":26,"block":4},[39,1922],{"$":1923},{"html":26,"block":4},[1925,1926],"hr",{"$":1927},{"html":26,"block":4},"本文转载自https:\u002F\u002Fwww.jb51.net\u002Farticle\u002F48862.htm",[72,1930],{"$":1931,"style":1932,"href":1933,"target":1934,"rel":78},{"html":26,"block":4},"padding: 0px; margin: 0px; color: #ff6600; outline: 0px; text-decoration-line: none;","https:\u002F\u002Fwww.jb51.net\u002Farticle\u002F48862.htm","_blank",[21,1936],{"$":1937},{"html":26,"block":4},[66,1939],{"$":1940,"class":168,"style":70},{"html":26,"block":4}]