Nā Alakaʻi Hōʻike Hōʻike Hou Hou (Regex) i WordPress

Regex - Nā Hōʻike maʻamau

No nā pule i hala iho nei, ke kōkua nei mākou i kahi mea kūʻai aku e hana i kahi neʻe paʻakikī me WordPress. ʻElua mau huahana a ka mea kūʻai aku, ua lilo lāua ʻelua i mea kaulana a hiki i ke kiko e hoʻokaʻawale lākou i nā ʻoihana, ka māka ʻana, a me ka ʻike i hoʻokaʻawale ʻia i nā kāʻei kapu. ʻO ka hana nō ia.

Ke waiho nei kā lākou kikowaena e kū nei, akā e loaʻa nā ʻike āpau i ka ʻāina hou e pili ana i kēlā huahana… mai nā kiʻi, nā kia, nā hihia hihia, nā hoʻoiho, nā palapala, ka ʻike ʻike, a pēlā aku. Ua hana mākou i kahi loiloi a kolo i ka pūnaewele e ʻike ʻaʻole makemake mākou 'aʻole e hala kekahi waiwai.

I ka manawa e loaʻa iā mākou ka pūnaewele hou ma kahi a me ka hana, ua hiki mai ka manawa e huki ai i ke kuapo a waiho ola. ʻO ia ka manaʻo e hoʻohuli ʻia nā URL mai ka pūnaewele mua e pili ana i kēia huahana i ka inoa hou. Mālama mākou i ka nui o nā ala kūlike ma waena o nā pūnaewele, no laila ke hoʻonohonoho nei ʻo kī i nā kuhikuhi ʻē aʻe.

E kuhikuhi i nā plugina ma WordPress

Aia he mau plugina kaulana ʻelua e hana i kahi hana maikaʻi loa no ka mālama ʻana i nā kuhikuhi me WordPress:

  • redirection - ʻo ia paha ka plugin maikaʻi loa ma ka mākeke, me nā mākaukau ʻōlelo maʻamau a me nā ʻāpana no ka mālama ʻana i kāu kuhikuhi.
  • ʻO Rankmath SEO - he hanu hou kēia plugin SEO māmā a hana i kaʻu papa inoa o ʻO nā plugina WordPress maikaʻi loa ma ka makeke. He alakaʻi ʻē aʻe ia ma ke ʻāpana o kāna mōhai a e hoʻokomo hoʻi i ka ʻikepili o Redirection inā ʻoe e neʻe iā ia.

Inā ʻoe e hoʻohana nei i kahi ʻenekini WordPress Manaʻo WordPress like WPEngine, he modula kā lākou e lawelawe ai i nā alualu hou ma mua o ka pā ʻana o ke kanaka i kāu pūnaewele ... kahi hiʻohiʻona maikaʻi loa e hiki ai ke hōʻemi i ka latency a me ka overhead ma kāu hoʻokipa ʻana.

A, ʻoiai, hiki iā ʻoe kākau i nā lula hoʻohuli i kāu faila .htaccess ma kāu kikowaena WordPress ... akā ʻaʻole wau e koi aku iā ia. ʻO ʻoe kahi hewa syntax mai ka hana ʻole ʻana i kāu pūnaewele!

Pehea e hana ai i kahi Regex Redirect

I ka laʻana aʻu e hāʻawi ai ma luna, he mea maʻalahi paha e hana i kahi hoʻohuli maʻamau mai kahi subf folder i ka domain hou a me ka subfolder.

Source: /product-a/
Destination: https://newdomain.com/product-a/

Aia kekahi pilikia me kēlā, eia nō naʻe. He aha inā inā ʻoe i hoʻokaʻawale i nā loulou a me nā hoʻouka kaua i loaʻa kahi querystring no ka hoʻouka kaua ʻana a i ʻole nā ​​mea kuhikuhi. ʻAʻole e hoʻohuli kūpono kēlā mau ʻaoʻao. Maliʻa paha ʻo URL:

https://existingdomain.com/product-a/?utm_source=newsletter

Ma muli o kāu kākau ʻana i kahi kūlike pololei, ʻaʻole e hoʻohuli kēlā URL i nā wahi āpau. No laila, e hoʻowalewale ʻia paha ʻoe e hana i kahi ʻōlelo maʻamau a hoʻohui i kahi kāleka hihi i ka URL:

Source: /product-a/(.*)
Destination: https://newdomain.com/product-a/

Maikaʻi loa ia, akā koe nō kekahi mau pilikia ʻelua. ʻO ka mea mua, e kūlike ia me kekahi URL / huahana-a / i loko o laila a hoʻohuli iā lākou āpau i kahi i kū ai. No laila e hoʻohuli hou kēia mau ala i kahi i kū ai.

https://existingdomain.com/product-a/
https://existingdomain.com/help/product-a/
https://existingdomain.com/category/parent/product-a/

ʻO nā hiʻohiʻona maʻamau kahi mea hana nani, akā. ʻO ka mea mua, hiki iā ʻoe ke hoʻohou i kāu kumuwaiwai e hōʻoia i ʻike ʻia ka pae folder.

Source: ^/product-a/(.*)
Destination: https://newdomain.com/product-a/

E hōʻoia kēlā i ka pae folder mua e hoʻihoʻi kūpono. I kēia manawa no ka pilikia lua ... pehea ʻoe e kiʻi ai i ka ʻike querystring i hoʻopaʻa ʻia ma ka pūnaewele hou inā ʻaʻole i hoʻokomo ʻia kāu hoʻohuli? ʻĀ, he ʻōlelo maikaʻi loa nā ʻōlelo maʻa mau no kēlā.

Source: ^/product-a/(.*)
Destination: https://newdomain.com/product-a/$1

Hoʻopaʻa maoli ʻia ka ʻikepili wildcard a hoʻopili ʻia i ka māka ma ka hoʻohana ʻana i ka loli. No laila…

https://existingdomain.com/product-a/?utm_source=newsletter

E hoʻohuli kūpono i:

https://newdomain.com/product-a/?utm_source=newsletter

E hoʻomanaʻo e hiki i ka kāleka hihiu ke hoʻohuli i kekahi subfolder me ia, no laila e hoʻohana ʻia kēia:

https://existingdomain.com/product-a/features/?utm_source=newsletter

E hoʻohuli hou iā:

https://newdomain.com/product-a/features/?utm_source=newsletter

ʻOiaʻiʻo, hiki i nā ʻōlelo maʻamau ke ʻoi aku ka paʻakikī ma mua o kēia ... akā makemake wale wau e hāʻawi i kahi laʻana wikiwiki o ka pehea e hoʻonohonoho ai i kahi regex hoʻokele wildcard e hele maʻemaʻe i nā mea āpau i kahi kāʻei hou.

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.