如何使用.htaccess設(shè)置網(wǎng)站主文件
2017-02-12 20:06:32
12374
根據(jù)自己代碼需求復(fù)制如下代碼到.htaccess文件
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html index.php
order deny,allow
上面代碼的意思是:網(wǎng)站默認(rèn)打開根目錄下文件的順序。首先是“index.html",若?有該文件,則打開“index.php"。如果是用asp語(yǔ)言開發(fā)的網(wǎng)站,代碼可以如下設(shè)置:
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html index.asp
order deny,allow
? 當(dāng)目錄中沒(méi)有“index.html”文件時(shí),默認(rèn)打開“index.asp”文件。
若果是新手站長(zhǎng),不清楚自己網(wǎng)站的開發(fā)環(huán)境,又想設(shè)置默認(rèn)打開靜態(tài)文件時(shí),可以考慮直接使用如下代碼。
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
DirectoryIndex index.html index.php index.asp index.shtml index.htm index.jsp index.aspx
deny,allow
代碼的意思大致和上面差不多,設(shè)置的是默認(rèn)打開網(wǎng)站目錄下文件的順序依次是index.html、index.php、index.asp、index.shtml、index.htm、index.jsp、index.aspx。
根據(jù)自己需要選擇,復(fù)制好相應(yīng)的代碼,粘貼到記事本,保存為".htaccess"文件。然后通過(guò)FTP上傳到網(wǎng)站的更目錄即可
會(huì)員登錄
賬號(hào)登錄還沒(méi)有賬號(hào)?立即注冊(cè)