htaccess: Txaij nplaub tshev thiab Hloov mus nrog Regex

redirect

Yooj yim rau koj cov qauv URL yog txoj hauv kev zoo rau kev ua kom koj lub xaib zoo rau ntau yam. Cov URL ntev ntev yog qhov nyuaj rau kev qhia nrog rau lwm tus, tuaj yeem txiav tawm hauv cov ntawv nyeem thiab email kho kom raug, thiab cov URL tsim cov kab ntawv nyuaj tuaj yeem xa cov cim tsis raug cai rau kev tshawb fawb ntawm qhov tseem ceeb ntawm koj cov ntsiab lus.

Yog tias koj lub vev xaib muaj ob lub URL:

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

Qhov twg koj xav tias muab cov ntawv sau nrog qhov tseem ceeb dua? Thawj qhov piv txwv muaj qhov sib cais ntawm tshooj thiab ntawm nplooj ntawv ntawm 5 theem. Yog tias koj yog tus tshawb nrhiav khoom, koj puas xav tias cov ntsiab lus tseem ceeb no?

Rau cov laj thawj no, peb ua kev yooj yim ntau ntawm peb cov neeg siv cov ntawv cim ua haujlwm. Qee tus tuaj yeem sib cav tias ob peb ntawm qeb slugs nrog cov ntsiab lus zoo dua, tab sis peb tsis tau pom qhov no nrog peb cov neeg siv khoom. Cov qib siab thiab tus naj npawb ntawm cov txuas los ntawm lub tsev nplooj ntawv tau tsav cov qeb duas zoo dua nrog peb cov ntsiab lus nrov.

Tom qab siv lub blog, tab sis, nws yog qhov mob me ntsis los tshem tawm tag nrho cov kev sib txuas mus tas li thiab tseem tau txais kev hloov tsheb mus los ntawm cov kev sib txuas uas twb muaj lawm tawm muaj rau tus qauv URL tshiab. Nrog flywheel (kev koom tes txuas nrog), peb tuaj yeem muaj lawv pab neeg tswj hwm peb qhov kev sib pheeb lossis peb tuaj yeem siv lub vijtsam txuas mus ntxiv.

  1. Ua ntej, peb ntiav Yoast's WordPress SEO plugin kom peb tuaj yeem hle cov lus ncaj ncees qeb sib zog ntaus tawm ntawm qhov URL.
  2. Tom ntej no, peb hloov kho permalinks thiab tshem tawm /% qeb% / thiab tsuas yog tawm /% post% / hauv thaj teb (thiab rov kho lub cache).
  3. Thaum kawg, peb yuav tsum ntxiv qhov kev qhia tawm tas li los hloov kev qhia:

sawb-nplaub tshev-redirect-regex

Cov lus hais muaj koj cov kev xaiv tau teev (folder1, folder2, folder3) thiab yuav tsum muaj qee cov ntawv sau tom qab qeb ... li no koj cov nplooj ntawv qeb tsis tawg tab sis cov ntawv ywj pheej yuav xa mus rau qhov URL tshiab.

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

Kuv tsis paub tseeb Kuv xav pom zoo qhov kev hloov loj no rau txhua lub tuam txhab. Cov neeg uas muaj qeb duas tsim yuav tsis xav siv qhov no. Hauv lub sijhawm luv luv, nws tuaj yeem ua phem rau koj qeb kev txij li ib txoj kab ke tsis nqa txhua txoj cai ntawm nplooj ntawv thawj. Tab sis dhau sijhawm, muaj cov ncauj lus ntau dua hauv koj qhov xwm txheej permalink tuaj yeem pab koj. Peb paub tias nws tau pab Martech Zone!

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.