Ukusebenza nefayela le-.htaccess Ku-WordPress

htaccess ifayela le-WordPress

WordPress iyipulatifomu enhle eyenziwe yenziwa ngcono ngokuthi inemininingwane futhi ibe namandla kangakanani ideshibhodi ejwayelekile ye-WordPress. Ungafezekisa okuningi, ngokwenza ngokwezifiso indlela isayithi lakho elizizwa ngayo nemisebenzi, ngokumane usebenzise amathuluzi i-WordPress enikeze ukuthi itholakale njengokujwayelekile.

Kuza isikhathi empilweni yanoma yimuphi umnikazi wewebhusayithi, noma kunjalo, lapho uzodinga ukudlula lokhu kusebenza. Ukusebenza neWordPress ifayela le-.htaccess kungaba yindlela eyodwa yokwenza lokhu. Leli fayela yifayela eliyinhloko isayithi lakho elincike kulo, futhi likhathazeke kakhulu ngokuthi izimvume zewebhusayithi yakho zisebenza kanjani.

Ifayela le-.htaccess lingasetshenziswa ukufeza izinto eziningi eziwusizo, noma kunjalo. Sake sazimboza ezinye zazo, kufaka phakathi inqubo yokwenza ukuqondisa kabusha kwe-regex ku-WordPress, nokubuka konke okuvame kakhulu ku- ukuqondiswa kabusha kweheda kweWordPress. Kuyo yomibili le mihlahlandlela, sifinyelele futhi sahlela ifayela le-.htaccess, kepha ngaphandle kokuchaza okuningi ngokuthi kungani ifayili likhona kwasekuqaleni, nokuthi ungalisebenzisa kanjani.

Leyo yinhloso yalesi sihloko. Okokuqala, sizobheka ukuthi ifayela le-.htaccess lenzani kusethaphu ejwayelekile ye-WordPress. Ngemuva kwalokho, sizochaza ukuthi ungayifinyelela kanjani, nokuthi ungahlela kanjani. Ekugcineni, sizokukhombisa ukuthi kungani ungahle uthande ukukwenza lokho.

Liyini Ifayela le-.htaccess?

Ake sisuse izisekelo endleleni kuqala. Ifayela le-.htaccess akuyona i-a Ifayela le-WordPress. Noma, ukulibeka ngokunembe kakhudlwana, ifayela le-.htaccess empeleni liyifayela elisetshenziswa amaseva wewebhu we-Apache. Lolu uhlelo isetshenziswa njengamanje ngamasayithi amaningi we-WordPress nabasingathi. Ngenxa yobuningi be-Apache uma kukhulunywa ngokuphatha amasayithi we-WordPress, isiza ngasinye esinjalo sinefayela le-.htaccess.

Ifayela le-. Igama lefayela yifayela elifihliwe futhi kuzodingeka lingafihlwa ukuze lihlelwe. Ibuye ihlale kumkhombandlela wezimpande wesayithi lakho le-WordPress.

Khumbula, ifayela le-.htaccess lenza into eyodwa nento eyodwa kuphela: linquma ukuthi izimvume zesayithi lakho ziboniswa kanjani. Yilokho kuphela. 

Okufihliwe ngemuva kwale ncazelo elula kuyinkimbinkimbi kakhulu, noma kunjalo. Lokhu kungenxa yokuthi abanikazi abaningi besiza, ama-plugins nezindikimba benza izinguquko endleleni ama-permalinks asetshenziswa ngayo ngaphakathi kwesiza sakho se-WordPress. Njalo lapho wena (noma i-plugin) wenza ushintsho endleleni ama-permalinks akho asebenza ngayo, lezi zinguquko zigcinwa kufayela le-.htaccess. 

Empeleni, lolu uhlelo oluhle impela, futhi luvikelekile. Kodwa-ke, emhlabeni wangempela kungadala izinkinga zangempela. Eyokuqala lokho kungenxa yokuthi Abathuthukisi abangama-75% basebenzisa iJavaScript, ngakho-ke akukhululekile ukusebenzisa i-Apache, ama-plugins amaningi angabhala ngaphezulu ifayela le-.htaccess ngendlela eshiya indawo yakho ingavikelekile. Ukulungisa (noma ukubona nokubona) lolu hlobo lwenkinga lungaphezu kwesilinganiso sethu lapha, kepha ama-caveats ajwayelekile mayelana nama-plugins ayasebenza - faka kuphela lawo owethembayo, futhi avuselelwa njalo ukulungisa izimbobo zokuphepha ezinjengalezi.

Ukuthola Nokuhlela Ifayela le-.htaccess

Ngaphandle kokuthi ifayili le-.htaccess lenzelwe ukuphatha ama-permalinks kusayithi lakho, ungahlela leli fayela ukuze uzuze imiphumela eminingi ewusizo: lokhu kufaka phakathi ukwenza ukuqondisa kabusha, noma ukumane uthuthukise ukuphepha kusayithi lakho ngokunqanda ukufinyelela ngaphandle amakhasi athile.

Kulesi sigaba, sizokukhombisa ukuthi ungakwenza kanjani lokho. Kepha kuqala… 

ISEXWAYISO: Ukuhlela ifayela le-.htaccess kungaphula iwebhusayithi yakho. 

Ukwenza noma yiluphi ushintsho kumafayili ayisisekelo isayithi lakho eligijima kuwo kuyingozi. Kumele yenza njalo isipele sesayithi lakho ngaphambi kokwenza noma yiziphi izinguquko kuyo, futhi uzame ngaphandle kokuthinta isayithi ebukhoma. 

Eqinisweni, kunesizathu esihle sokuthi kungani ifayela le-.htaccess lingatholakali kubasebenzisi abaningi be-WordPress. I-WordPress inenqwaba ecacile yesabelo semakethe yamawebhusayithi amabhizinisi amancane, futhi lokhu kusho ukuthi iningi labasebenzisi bayo, singathi, akuyona ethambekele kakhulu kwezobuchwepheshe. Kungakho ifayela le-.htaccess lifihliwe ngokuzenzakalela - ukugwema abasebenzisi be-novice abenza amaphutha.

Ukungena Nokuhlela Ifayela le-.htaccess

Ngalokho konke okusendleleni, ake sibheke ukuthi ungangena kanjani kufayela le-.htaccess. Ukuze wenze lokho:

  1. Dala ukuxhumeka kuwebhusayithi usebenzisa iklayenti le-FTP. Kunenqwaba yamakhasimende wamahhala, amahle we-FTP laphaya, kufaka phakathi FileZilla. Funda imibhalo enikeziwe ukwenza uxhumano lwe-FTP kusayithi lakho.
  2. Lapho ususungule ukuxhumana kwe-FTP, uzoboniswa wonke amafayela akha isiza sakho. Bheka lawa mafolda, futhi uzobona eyodwa ebizwa ngokuthi umkhombandlela wezimpande.
  3. Ngaphakathi kwale folda, uzobona ifayela lakho le-.htaccess. Kuzoba seduze kwaphezulu kohlu lwamafayela kuleyo folda. Chofoza kufayela, bese uqhafaza ukubuka / ukuhlela. 
  4. Ifayela lizovuleka kusihleli sombhalo.

Futhi yilokho kuphela. Manje uvunyelwe ukwenza izinguquko kufayela lakho, kepha qaphela ukuthi ungahle ungafuni ukwenza lokho. Sizokukhombisa ukuthi leli fayela ulisebenzisa kanjani esigabeni esilandelayo, kepha ngaphambi kokuthi sikwenze kuwumqondo omuhle lokho yenza ikhophi lendawo wefayela lakho le-.htaccess (usebenzisa ibhokisi elijwayelekile elithi “save as”), yenza izinguquko zakho endaweni yangakini, bese ulayisha lelo fayela kusayithi elihleliwe (njengoba sibonile ngenhla).

Kusetshenziswa Ifayela le-.htaccess

Manje usukulungele ukuqala ukusebenzisa ukusebenza okungeziwe okunikezwe yifayela le-.htacess. Ake siqale ngezimbalwa eziyisisekelo.

  • I-301 iqondisa kabusha - Ukuqondisa kabusha okungu-301 ucezu oluncane lwekhodi lokho kuthumela izivakashi kusuka ekhasini elilodwa kuya kwelinye, futhi kuyadingeka uma udlulisa iposi elithile le-blog elixhunywe kusayithi langaphandle. Ngenye indlela, ungasebenzisa ifayela le-.htaccess ukuqondisa kabusha iwebhusayithi. Ungaqondisa futhi izivakashi kusuka kunguqulo endala ye-HTTP yesayithi iye enguqulweni entsha, ephephe kakhudlwana, ye-HTTPS. Faka lokhu kufayela le-.htacess:

Redirect 301 /oldpage.html /newpage.html

  • Security - Kukhona nezindlela eziningi zokusebenzisa ifayela le-.htaccess ukusebenzisa amasu okuphepha athuthukile we-WP. Enye yalezi uku vala ukufinyelela kumafayili athile ukuze abasebenzisi abanokufakazela ubuqiniso obufanele kuphela abangafinyelela kumafayili ayinhloko isayithi lakho le-WordPress elisebenza kuwo. Ungasebenzisa le khodi, efakwe ekugcineni kwefayela lakho le-.htaccess, ukukhawulela ukufinyelela kwinombolo yamafayela ayisisekelo:

<FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
Order deny,allow
Deny from all
</FilesMatch>

  • Shintsha ama-URL - Esinye isici esiwusizo sefayela le-.htaccess, noma ngabe liyinkimbinkimbi ukwenziwa, ukuthi lelo fayela lingasetshenziswa ukulawula indlela ama-URL akhonjiswa ngayo lapho izivakashi zakho zingena kusayithi lakho. Ukuze wenze lokho, kuzodingeka uqiniseke ukuthi usebenzisa inguqulo yakamuva ye-Apache. Lokhu kwenza i-URL yekhasi elilodwa ibonakale yehlukile kuzivakashi. Lesi sibonelo sokugcina - mhlawumbe - siyinkimbinkimbi kakhulu kubasebenzisi abaningi abasanda kujwayela ifayela le-.htaccess. Noma kunjalo, ngiyifakile ukukukhombisa ubukhulu bokuthi yini engafinyelelwa ngefayela. Faka lokhu kufayela lakho le-.htaccess:

RewriteEngine on
RewriteRule ^oranges.html$ apples.html

Ukuqhubeka Ngokuqhubekayo Nge-.htaccess

Ukusebenza nefayela le-. Uma usukwazi ukusebenza nefayela le-.htaccess ngokwenza izinguquko eziyisisekelo esizichazile ngenhla, ingcebo yezinketho ikuvulela. Eyodwa, njengoba sike sahlanganisa ngaphambili, yikhono lokukwenza setha kabusha ibhulogi yakho ye-WordPress

Okunye ukuthi izindlela eziningi zokwenza ngcono ukuphepha kwakho kwe-WordPress zibandakanya ukushintsha ifayela le-.htaccess ngqo, noma ukusebenzisa uhlelo olufanayo lwe-FTP ukwenza ushintsho kwamanye amafayela wezimpande. Ngamanye amagama, uma uqala ukubuka amantongomane namabhawodi wesayithi lakho, uzothola amathuba angapheli wokwenza ngezifiso nokwenza ngcono.

UCABANGANI?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda ukuthi idatha yakho yokuphawula isetshenziswa kanjani.