htaccess: E wehe i ka faila a hoʻokele me Regex

hoʻoponopono hou

ʻO ka maʻalahi ʻana i kāu hanana URL kahi ala maikaʻi loa e hoʻonui i kāu pūnaewele no nā kumu he nui. He paʻakikī nā URL lōʻihi e kaʻana like me nā poʻe ʻē aʻe, hiki keʻoki ʻia i nā luna hoʻoponopono huaʻōlelo a me nā luna hoʻoponopono leka uila, a hiki i nā hanana folder URL paʻakikī ke hoʻouna i nā hōʻailona hewa i nā ʻenekia huli i ka nui o kāu ʻike.

Inā ʻelua mau URL i kāu pūnaewele:

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

ʻO wai kāu e manaʻo ai i hāʻawi mai i ka ʻatikala me nā mea nui aʻe? ʻO ka laʻana mua he hoʻokaʻawale ma waena o ka ʻatikala a me ka ʻaoʻao home o 5 pae. Inā ʻoe he ʻenekia huli, manaʻo paha ʻoe he ʻike nui kēia?

No kēia mau kumu, hoʻomaʻalahi mākou i nā hanana folder o nā mea kūʻai aku. Hiki i kekahi ke hoʻopaʻapaʻa he ʻoi aku ka maikaʻi o nā slug waeʻano me nā huaʻōlelo nui, akā ʻaʻole mākou i ʻike i kēia me kā mākou mea kūʻai aku. ʻO ka hierarchy a me ka helu o nā loulou mai ka ʻaoʻao home i kipaku aku i nā kūlana kiʻekiʻe me kā mākou ʻike punahele.

Ma hope o ka hoʻokō ʻana i kahi blog, eia nō naʻe, ʻehaʻeha ia e wehe i kēia mau loulou mau loa a hoʻokele pono hoʻi i nā kaʻa mai nā loulou i kēia manawa ma laila i ka hanana URL hou. Me Flywheel (loulou pili), hiki iā mākou ke hoʻokau i kā lākou hui i kā mākou hoʻohuli a i ʻole hiki iā mākou ke hoʻohana i ka plugin redirection.

  1. ʻO ka mea mua, hana mākou ʻO Yoast's WordPress SEO kuʻina i hiki iā mākou ke hemo i ka huaʻōlelo slug waeʻano mai ka URL.
  2. A laila, hōʻano hou mākou i nā permalinks a hemo /% waeʻano% / a waiho wale /% kia% / i ke kula (a hōʻoluʻolu i ka cache).
  3. ʻO ka mea hope loa, pono mākou e hoʻohui i kahi ʻōlelo maʻamau e hoʻohuli pono i ka waihona.

pākuʻi-folder-redirect-regex

Aia i ka māmala'ōlelo kāu mau koho koho i helu ʻia (folder1, folder2, folder3) a koi i kekahi mau huaʻōlelo ma hope o ka mahele ... ʻo kēia ala ʻaʻole e haki kāu ʻaoʻao ʻaoʻao akā e neʻe kūpono nā ʻatikala kūʻokoʻa i ka URL hou.

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

ʻAʻole maopopo iaʻu makemake wau e paipai i kēia hoʻololi nui no kēlā me kēia ʻoihana. ʻAʻole makemake ka poʻe me kahi kūlana hoʻokumu e hoʻohele i kēia. I ka wā pōkole, hiki iā ia ke hōʻeha i kāu kūlana ma muli o ka lawe ʻole ʻana o kahi hoʻohuli i ka mana o ka ʻaoʻao kumu. Akā i ka hala ʻana o ka manawa, ʻo ka loaʻa ʻana o nā ʻike i ʻoi aku i luna i kāu hierarchy permalink hiki ke kōkua iā ʻoe. ʻIke mākou ua kōkua ʻia Martech Zone!

Pehea kou manaʻo?

Ke hoʻohana nei kēia pūnaewele i ka Akismet e ho'ēmi i ka spam. E aʻo pehea e hanaʻia ai kāuʻikeʻikepili.