Tus Tswv Tshiab Tso Npe Tawm Tshwj Xeeb (Regex) Redirects Hauv WordPress

Regex - Kab Lus Qhia

Rau ob peb lub lis piam dhau los, peb tau pabcuam tus neeg tau los ua ib qhov kev tsiv teb tsaws nrog WordPress. Tus neeg siv khoom muaj ob yam khoom, ob qho tib si los ua lub npe nrov uas lawv yuav tsum tau faib tawm cov lag luam, cov khoom lag luam, thiab cov ntsiab lus tawm kom nyias muaj nyias. Nws yog qhov nyuab heev!

Lawv cov chaw uas twb muaj lawm nyob rau hauv, tab sis tus sau tshiab yuav muaj tag nrho cov ntsiab lus nrog kev hwm txog cov khoom ntawd ... los ntawm cov duab, cov ncauj lus, cov ntaub ntawv tshawb fawb, rub tawm, cov ntawv, kev paub, thiab lwm yam. 't nco ib lub cuab tam.

Thaum peb muaj lub xaib tshiab rau hauv qhov chaw thiab ua haujlwm, lub sijhawm rub tawm tus tes hloov pauv thiab muab tso rau nws tau nyob. Qhov ntawd txhais tau hais tias txhua qhov URLs los ntawm cov thawj lub vev xaib uas tau koom nrog cov khoom no yuav tsum tau xa mus rau qhov chaw sau npe tshiab. Peb khaws cia feem ntau cov kab xwm sib luag ntawm cov xaib, yog li ntawd tseem ceeb tau teeb tsa qhov kev hloov pauv yam tsis raug cai.

Redirect Plugins hauv WordPress

Muaj ob qhov nrov tshaj plaws plugins muaj uas ua tau zoo txoj haujlwm ntawm kev tswj kev rov qab nrog WordPress:

  • Kev Tawm Tshiab - tej zaum qhov zoo tshaj plaws plugin ntawm kev ua lag luam, nrog cov peev xwm hais tawm tsis tu ncua thiab txawm tias pawg rau tswj hwm koj rov qab.
  • Rankmath SEO - lub tshuab SEO hnyav no ua pa ntawm huab cua ntshiab thiab ua rau kuv daim ntawv teev npe Qhov zoo tshaj plaws Plugins WordPress nyob rau kiab khw. Nws muaj redirects ua ib feem ntawm nws txoj kev xyeem thiab txawm yuav import Redirection cov ntaub ntawv yog tias koj tsiv mus rau nws.

Yog tias koj siv Managed WordPress Hosting cav zoo li WPEngine, lawv muaj cov qauv los tswj cov redirects ua ntej tus neeg puas tau ntaus koj lub xaib ... ib qho zoo nkauj zoo nkauj uas tuaj yeem txo latency thiab nyiaj siv ua haujlwm ntawm koj hosting.

Thiab, ntawm chav kawm, koj tuaj yeem ua tau sau cov cai pauv rau koj .htaccess ntawm koj lub WordPress server… tab sis kuv tsis xav kom ua. Koj nyob nraum ib qho yuam kev lawm tsis ua rau koj lub xaib nkag tsis tau!

Yuav Ua Li Cas Tsim Ib Regex Redirect

Hauv qhov ua piv txwv Kuv muab qhia saum toj no, nws yuav zoo li yooj yim rau cia li ua ib qho kev sib pauv ntawm lub subfolder mus rau lub chaw sau npe tshiab thiab subfolder:

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

Muaj qhov teeb meem nrog qhov ntawd, txawm hais tias. Yuav ua li cas yog tias koj tau faib cov chaw txuas thiab cov phiaj xwm uas muaj cov lus nug rau kev sib tw khiav lossis kev xa mus ntxiv? Cov nplooj ntawv yuav tsis ua pauv zoo. Kab tias qhov URL yog:

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

Vim tias koj tau sau qhov tseeb, qhov URL ntawd yuav tsis hloov qhov twg! Yog li, koj yuav raug ntxias kom ua ib qho kev hais tawm tas li thiab ntxiv cov cim rau kab URL:

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

Ntawd zoo nkauj heev, tab sis tseem muaj ob peb teeb meem. Ua ntej, nws yuav mus phim nrog txhua URL nrog / khoom-a / hauv nws thiab hloov lawv txhua qhov mus rau tib lub hom phiaj. Yog li tag nrho cov kev no yuav hloov mus rau tib qho chaw.

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

Kev hais tawm tas li yog qhov cuab yeej zoo nkauj, tab sis. Ua ntej, koj tuaj yeem hloov kho koj cov khoom siv los xyuas kom meej tias daim nplaub tshev qib tau txheeb xyuas.

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

Uas yuav xyuas kom meej tias tsuas theem pib daim nplaub tshev yuav hloov kho kom raug. Tam sim no rau qhov teeb meem thib ob… koj yuav ua li cas thiaj li tau txais cov ntaub ntawv cov lus nug ntawm lub vev xaib tshiab yog tias koj qhov ncauj lus tsis suav nrog? Zoo, cov kev hais tawm tas li muaj cov kev daws teeb meem zoo rau qhov ntawd:

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

Cov lus qhia txog kev sib tw yeej tau yuav ntes thiab txuas ntxiv rau qhov chaw uas yog siv tus nqi sib txawv. Yog li…

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

Yuav kom hloov mus rau:

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

Nco ntsoov tias daim npav ntsuab yuav ua kom txhua tus neeg xa ntawv hauv qab kom rov ua haujlwm tau zoo, yog li qhov no tseem yuav ua kom rov ua haujlwm:

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

Yuav pauv mus rau:

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

Tau kawg, cov kab lus tsis tu ncua tuaj yeem tau txais ntau tshaj qhov nyuaj no ... tab sis kuv tsuas yog xav muab piv txwv ceev ntawm yuav ua li cas teeb tsa wildcard regex rov qab uas dhau txhua yam huv si rau qhov hloov tshiab!

Yuav ua li cas koj xav hais tias?

Qhov Web site no siv Akismet los txo cov kev pabcuam. Kawm li cas koj cov ntaub ntawv tawm tswv yim tiav.