您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“Nginx服務(wù)器下如何配置使用索引目錄”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
nginx配置
location ~ ^/2589(/.*) { autoindex on; //開啟 autoindex_localtime on;//開啟顯示功能 }
auto_index指令
語法: autoindex on | off;
配置段: autoindex off;
配置段: http, server, location
啟用/僅用nginx目錄索引功能.
語法: autoindex_exact_size on | off;
配置段:autoindex_exact_size on;
配置段: http, server, location
制定是否額外得顯示文件得大小,單位為字節(jié),mb,gb等等. 默認(rèn)是打開得
syntax: autoindex_localtime on | off;
配置段: autoindex_localtime off;
配置段: http, server, location
指定是否顯示目錄或者文件得時間,默認(rèn)是不顯示。
nginx+fancy實現(xiàn)漂亮的索引目錄
nginx索引目錄自帶的功能很簡單,而且不好看,如何做一個漂亮的索引列表.接下來看.
安裝環(huán)境
系統(tǒng):centos 6.3nginx:1.4.2
fancy: http://wiki.nginx.org/ngxfancyindex
下載安裝fancy
對比一下nginx內(nèi)置的index效果(上篇文章貼過來的圖),如下
# wget http://gitorious.org/ngx-fancyindex/ngx-fancyindex/archive-tarball/master # tar -xzvf master # wget http://nginx.org/download/nginx-1.4.2.tar.gz # tar -xzvf nginx-1.4.2.tar.gz # cd nginx-1.4.2 # ./configure --prefix=/usr/local/nginx-1.4.2 --add-module=../ngx-fancyindex-ngx-fancyindex # make # make install
fancy索引配置
server { listen 80; server_name test.jb51.net; access_log /data/logs/nginx/test.jb51.net.access.log main; index index.html index.php index.html; root /data/site/test.jb51.net; location / { } location ~ ^/2589(/.*) { fancyindex on; fancyindex_exact_size off; fancyindex_localtime on; fancyindex_footer "myfooter.shtml"; } }
看看nginx加了fancy的效果,如下圖.
比自帶的好看多少,這個不好說...反正就是....變好看了點~
參數(shù)解釋:
fancyindex on:開啟fancy索引
fancyindex_exact_size off:不使用精確的大小,使用四舍五入,1.9m會顯示為2m這樣.如果開啟的話,單位為字節(jié)
fancyindex_localtime on:使用本地時間
fancyindex_footer "myfooter.shtml":把當(dāng)前路徑下的myfooter.shtml內(nèi)容作為底部.文件不存在底部會出現(xiàn)404
myfooter.shtml內(nèi)容如下:
<!-- footer start --> <div id="footer"> <a id="gotop" href="#" onclick="mgjs.gotop();return false;">回到頂部</a> <a id="powered" href="http://wordpress.org/">wordpress</a> <div id="copyright"> 版權(quán)所有 © 2006-2015 億速云 </div> <div id="themeinfo"> <a href="//www.jb51.net/about/">關(guān)于我們</a> | <a href="//www.jb51.net/sitemap.html">網(wǎng)站導(dǎo)航</a> | <a href="//www.jb51.net/sitemap.xml">網(wǎng)站地圖</a> |<a rel="nofollow" href="http://www.miibeian.gov.cn/">蘇icp備14036222號</a> </div> </div> <!-- footer end --> fancy指令使用:
fancyindex
語法:
*fancyindex* [*on* | *off*]
默認(rèn)值: fancyindex off
配置塊: http, server, location
描述: 開啟/關(guān)閉目錄索引功能
fancyindex_css_href
語法:
*fancyindex_css_href uri*
默認(rèn)值: fancyindex_css_href ""
配置塊: http, server, location
描述: 外置css路徑,這個css將會替代掉現(xiàn)有的css樣式。如果你會css,那你可以把索引列表做得更加漂亮.咱們ttlsa沒有網(wǎng)頁設(shè)計師,所以只能用自帶的了^^
fancyindex_exact_size
語法:
*fancyindex_exact_size* [*on* | *off*]
默認(rèn)值: fancyindex_exact_size on
配置塊: http, server, location
描述: 定義如何顯示文件的大小,默認(rèn)是on,on:文件大小使用精確值,單位為字節(jié).off:單位為kb,mb,gb,如果含有小數(shù)點,將會四舍五入。例如1.9mb,將會顯示為2mb。
fancyindex_footer
語法:
*fancyindex_footer path*
默認(rèn)值: fancyindex_footer ""
配置塊: http, server, location
描述: 指定哪個文件嵌入到索引頁面的底部,效果請看本文的第一張圖片
fancyindex_header
語法:
*fancyindex_header path*
默認(rèn)值: fancyindex_header ""
配置塊: http, server, location
描述: 指定哪個文件嵌入到索引頁面的頭部.用法和fancyindex_footer類似
fancyindex_ignore
語法:
*fancyindex_ignore string1 [string2 [... stringn]]*
默認(rèn)值: no default.
配置塊: http, server, location
描述: 哪些文件/目錄隱藏掉,如果你的nginx支持正則,那么可以使用正則表達(dá)式來過濾
例如我想隱藏dir打頭的文件或目錄以及文件filea.txt,配置如下:
fancyindex_ignore "dir*" "filea.txt"
fancyindex_localtime
語法:
*fancyindex_localtime* [*on* | *off*]
默認(rèn)值: fancyindex_localtime off
配置塊: http, server, location
“Nginx服務(wù)器下如何配置使用索引目錄”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。