htaccess: Ifolda yomtya kunye nokuKhangela kwakhona ngeRegex

ezingo-

Ukwenza lula ulwakhiwo lwakho lwe-URL yindlela elungileyo yokwenza indawo yakho isebenze ngezizathu ezininzi. Ii-URLs ezinde kunzima ukuzibandakanya nabanye, zinokunqunyulwa kubahleli beetekisi kunye nabahleli be-imeyile, kunye nolwakhiwo olunzima lwe-URL olunokuthumela imiqondiso engalunganga kwiinjini zokukhangela ngokubaluleka komxholo wakho.

Ukuba indawo yakho ibinee-URLs ezimbini:

  • https://martech.zone/blog/category/search-engine-optimization/htaccess-folder-redirect-regex OR
  • https://martech.zone/htaccess-folder-redirect-regex

Ngowuphi ocinga ukuba unike inqaku ngokubaluleka okungaphezulu? Umzekelo wokuqala ukwahlula phakathi kwenqaku kunye nephepha lasekhaya lamanqanaba ama-5. Ukuba ubuyinjini yokukhangela, ngaba ucinga ukuba oku kubalulekile?

Ngezi zizathu, senza lula uninzi lwezakheko zabalawuli zeefolda. Abanye banokuphikisa ukuba ii-slugs zodidi olunamagama aphambili zingcono, kodwa asikayiboni le nto kubaxumi bethu. Ubukhosi kunye nenani lamakhonkco kwiphepha lasekhaya liqhubele phambili amazinga ngokungcono kunye nomxholo wethu othandwayo.

Emva kokumiliselwa kwebhlog, nangona kunjalo, kuyintlungu ukulungisa zonke ezi amakhonkco asisigxina kwaye uqondise ngokufanelekileyo ukugcwala kwezithuthi ukusuka kumakhonkco akhoyo phaya kwisakhiwo esitsha se-URL. Kunye Flywheel (ikhonkco lokudibana), sinokuba neqela labo lilawule ukuhanjiswa kwethu kwakhona okanye sinokusebenzisa iplagi yolwalathiso.

  1. Okokuqala, siqesha I-SEO yeOxpress yeWordPress iplagi ukuze sihlube ngokoqobo udidi slug ngaphandle kwe-URL.
  2. Emva koko, sihlaziya ii-permalinks kwaye sisuse /% isigaba% / kwaye shiya /% post% / ebaleni (kwaye uhlaziye i-cache).
  3. Okokugqibela, kufuneka songeze intetho eqhelekileyo ukuze siqondise ngokufanelekileyo kwifolda:

strip-ifolda-phinda uthumele-regex

Ibinzana lineendidi ozikhethileyo ezidwelisiweyo (ifolda1, ifowulda2, ifowulda3) kwaye ifuna isicatshulwa esithile emva kodidi ... ngale ndlela amaphepha odidi lwakho awayi kwaphuka kodwa amanqaku azimeleyo aya kudlulisela phambili kwi-URL entsha.

^/(folder1|folder2|folder3)/([a-zA-Z0-9_.-]+)$

Andiqinisekanga ukuba ndingacebisa olu tshintsho lukhulu kuyo yonke inkampani. Abo banenqanaba elimiselweyo abanakunqwenela ukukuhambisa oku. Ngexesha elifutshane, inokulimaza inqanaba lakho kuba ukuhanjiswa kwakhona akunalo lonke igunya lephepha lokuqala. Kodwa ixesha elingaphezulu, ukuba nomxholo ongaphezulu phezulu kulawulo lwakho lwepermalink kunokukunceda. Siyazi ukuba iyancedwa Martech Zone!

Ingaba ucinga ntoni?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda indlela idatha yakho yokubhaliweyo isetyenziswe ngayo.