Yog tias koj lub vev xaib, zoo li feem ntau cov vev xaib hauv lub network, yog tuav ntawm ib tus Apache server, ces txoj kev yooj yim tshaj plaws lo lus zais-tiv thaiv qee cov nplooj ntawv yog siv cov ntawv tso cai los ua rau lub server no los ntawm htaccess. Hauv qhov no, koj yuav tsis tas yuav tsum hloov pauv cov peev txheej ntawm nplooj ntawv thiab kev paub ntawm cov lus programming tsis tas yuav tsum muaj.
Cov Lus Qhia
Kauj ruam 1
Tsiv cov nplooj ntawv uas koj xav kom tiv thaiv (password) rau ib daim nplaub tshev cais rau ntawm tus neeg rau zaub mov. Yog tias cov ntawv tso cai yuav tsum ua haujlwm rau tag nrho cov nplooj ntawv ntawm lub xaib, tom qab ntawv no tsis xav tau.
Kauj ruam 2
Tsim cov kev pabcuam cov ntaub ntawv htaccess. Qhov no yog cov ntawv sau ua ntu zus, yog li koj tuaj yeem siv ib qho ntawv nyeem los kho ua haujlwm nrog nws. Nws yuav tsum muaj cov lus qhia rau lub software software: AuthType Basic
AuthName "Kev nkag mus rau cov nplooj ntawv no yuav tsum muaj kev pom zoo!"
AuthUserFile /usr/yourAccount/yourSite/.htpasswd
yuav tsum siv cov neeg siv Siv AuthType Basic cov lus qhia ntawm thawj kab kom tus txheej txheem tso cai siv. Nws yog hu ua "qhov pib" vim tias tus password nkag los ntawm tus qhua ces tom qab ntawd xa los ntawm lub browser mus rau server nkag (encryption) siv cov Base64 algorithm. Cov lus qhia ntxiv (AuthName) muaj cov ntawv sau uas tus qhua yuav pom nyob hauv daim ntawv tso cai. Koj tuaj yeem hloov nws nrog ib qho sib txawv. Qhov AuthUserFile qhia meej tag nrho txoj hauv kev ntawm cov ntawv uas yuav khaws cov neeg siv logins thiab password. Cov lus qhia kawg (AuthUserFile) txhais cov ntsiab lus lees paub qhov tseeb. Tus nqi siv-siv tau txhais tau tias cov neeg siv uas tau sau cia rau hauv cov ntaub ntawv sau tseg nyob hauv AuthUserFile kev qhia tuaj yeem raug tso cai nkag mus rau nplooj ntawv tiv thaiv password.
Kauj ruam 3
Khaws cov ntaub ntawv nrog cov ntawv qhia hauv qab lub npe.htaccess - nco ntsoov tias nws tsis muaj npe, tsuas yog ncua ntxiv.
Kauj ruam 4
Tsim cov ntaub ntawv nrog cov npe ntawm kev nkag thiab password rau nkag mus tiv thaiv nplooj ntawv. Txhawm rau ua li no, siv cov khoom siv htpasswd.exe los ntawm Apache server software. Koj tuaj yeem rub tawm nws, piv txwv, ntawm no - https://www.intrex.net/techsupp/htpasswd.exe. Nws ua haujlwm rau cov kab hais kom ua, yog li koj yuav tsum tau pib lub davhlau ya nyob twg - nias qhov tseem ceeb ua ke WIN + R, nkag rau qhov hais kom ua cmd thiab nias tus yuam sij Sau
Kauj ruam 5
Ntawm qhov lus hais kom ua, hom: htpasswd -cm.htpasswd UserOne Tus-hloov kho qhia tus nqi hluav taws xob los tsim cov ntawv tshiab thiab siv MD5 rau encryption. Yog tias m hauv kev hloov kho yog hloov los ntawm d, tom qab ntawd DES encryption algorithm yuav siv, yog tias s - tom qab ntawd SHA algorithm, thiab p tus hloov kho yuav xiam qhov yuam kev zais password. UserOne yog lub npe nkag, nkag mus rau lub npe koj xav tau. Tom qab koj nias tus yuam sij Enter, lub chaw tso dej yuav hais kom koj sau tus password rau tus neeg siv no. Yog tias koj xav tau ntxiv rau tus siv tom ntej, tom qab ntawd khiav cov nqi hluav taws xob dua, tab sis tsis txhob siv tsab ntawv "c" hauv kev hloov kho.
Kauj Ruam 6
Muab cov ntaub ntawv generated.htaccess thiab.htpasswd rau koj lub vev xaib xaib.. Htaccess cov ntaub ntawv yuav tsum tau khaws tseg rau hauv cov npe sib txawv ntawm qhov chaw tiv thaiv (password), thiab.htpasswd cov ntaub ntawv yuav tsum muab tso rau hauv qhov chaw, tag nrho txoj hauv kev uas tau teev tseg rau hauv AuthUserFile qhia.