.htaccess exclude 301 redirect bypass pseudo static exception folder directory rule

WordPress Cov vev xaib raug xa mus rau hauv Apache siv .htaccess cov ntaub ntawv txhawm rau txheeb xyuas cov cai rov sau dua.

Txawm li cas los xij, qee zaum thaum muaj lwm yam kev pab cuam, xws li:CWP kev cai subdomain folder directory path hloov vhosts file, koj yuav tsum tsis suav nrog 301 redirect exception folder directory los hla txoj cai pseudo-static ntawm WordPress.

Nov yog ib txoj hauv kev ua tau.

.htaccess cov ntaub ntawv ntxiv tsis suav nrog cov ntawv teev npe cov cai 

.htaccess exclude 301 redirect bypass pseudo static exception folder directory rule

Yog muajYuav cia li dhia mus rau theem thib ob lub npe sau npe yam tsis muaj www top-level domain name, koj yuav tsum tau ntxiv ib redirection exclusion nplaub tshev directory txoj cai nyob rau hauv cov ntaub ntawv .htaccess ▼

RewriteCond %{REQUEST_URI} !^/img.chenweiliang.com/.*$ [NC]

Muab cov cai no ua ntej thawj txoj cai kom ua tiav cov npe teev tseg tsis suav nrog ua haujlwm ▼

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/img.chenweiliang.com/.*$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
  • Tom qab cov kev teeb tsa pib siv, nkag mus rau hauv cov ntawv teev npe /img.chenweiliang.com/ Cov nplooj ntawv hauv yuav tsis ua tiav los ntawm WordPress.

Secondary directory /go/ tsis tuaj yeem raug xa rov qab

Chen WeiliangBlog sivWordPress pluginGTranslate them version, xyuas kom tseeb tias GTranslate plug-in tsis siv / mus / raws li cov npe thib ob thiab lub npe thib ob.

Pom siv Pretty Link plugin ntxiv rau redirectsChen Weiliangblog covTelegramThaum sib txuas channel:
https://www.chenweiliang.com/go/tgchannel

  • (Qhov no yog vim qhov redirect link ntawm Pretty Link plug-in yog overwritten los ntawm RewriteRule redirection txoj cai nyob rau hauv cov ntaub ntawv .htaccess)

Nws yuav cia li dhia mus rau lub npe tsis muaj nyob hauv subdomain:
http://go. chenweiliang.com/go/tgchannel

  • (Yuav kom tsis txhob tuag txuas, ntxiv qhov chaw tom qab mus. hauv qhov txuas saum toj no)

Txawm li cas los xij, hauvChen WeiliangTshawb nrhiav hauv blog's .htaccess cov ntaub ntawv tsis pom RewriteRule muaj /go/.

Thaum kuv sim rho tawm GTranslate config RewriteRule, qhov txuas no tau ua tiav redirected:
https://www.chenweiliang.com/go/tgchannel

  • Yog li, kuv paub tseeb tias nws yog GTranslate config RewriteRule uas ua rau qhov yuam kev hloov pauv rau subdirectory txuas / mus / .

Yuav ua li cas cais / mus / subdirectory redirection?

Yog tsim nyogTeeb tsaTxhawm rau tshem tawm ntau qhov sib txawv subdirectories, koj tuaj yeem xa mus rau cov cai hloov pauv hauv qab no ntxiv rau lawv ▼

RewriteCond %{REQUEST_URI} !^/?(directory1|directory2)($|/)
  • directory1|directory2|etc Muab tus lej uas yuav tsum tau muaj rau hauv nws.
  • Qhov no yuav tsum yog "yog tias REQUEST_URI tsis pib nrog /directory1 lossis /directory2".

Nws yuav phim:

  • /directory1/dasdas
  • / directory1
  • / directory1/

thiab ntau ntxiv ……

Yuav ua li cas cais / mus / dhia txuas hauv RewriteRule?

Tsuas yog ntxiv cov hauv qab no "Exclude /go/ subdirectory redirection" txoj cai saum toj no GTranslate redirection txoj cai ▼

# Exclude /go/ subdirectory redirection
RewriteCond %{REQUEST_URI} !^/?(go)($|/)

### BEGIN GTranslate config ###
RewriteRule ^([a-z]{2}|af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ http://$1.chenweiliang.com/$2 [R=301,L,QSA]

RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ /$1/$3 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)/(.*)$ /wp-content/plugins/gtranslate/url_addon/gtranslate.php?glang=$1&gurl=$2 [L,QSA]
RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)$ /$1/ [R=301,L]
### END GTranslate config ###

Cia siab Chen Weiliang Blog ( https://www.chenweiliang.com/ ) qhia ".htaccess excludes 301 redirects and bypasses pseudo-static exception folder directory rules", uas yog pab tau rau koj.

Zoo siab txais tos los qhia qhov txuas ntawm kab lus no:https://www.chenweiliang.com/cwl-28236.html

Zoo siab txais tos rau Telegram channel ntawm Chen Weiliang blog kom tau txais qhov hloov tshiab tshiab!

🔔 Ua thawj tus tau txais txiaj ntsig "ChatGPT Content Marketing AI Tool Usage Guide" hauv cov npe saum toj kawg nkaus channel! 🌟 ib
📚 Daim ntawv qhia no muaj nuj nqis loj, 🌟Qhov no yog lub sijhawm tsis tshua muaj, tsis txhob nco nws! ⏰⌛💨
Share thiab like yog tias koj nyiam!
Koj qhov kev sib koom thiab kev nyiam yog peb qhov kev txhawb nqa tas mus li!

 

评论 评论

Koj email chaw nyob yuav tsis tsum luam tawm. Yuav tsum tau siv cov liaj teb * Ntaus Cim

scroll rau saum