WordPress: tshem qhov URL sau dua tshiab txoj cai phau qhia .htaccess

Li cas los ncaj qha mus saib ib directory rau cov hauv paus hniav ntawm tus neeg rau zaub mov hosting yog WordPress yog configured mus ua hauj lwm nrog ib tus phooj ywg URL?

htaccess

Teeb meem

Peb yeej paub tias thaum koj yuav nkag ib directory rau cov hauv paus hniav ntawm tus neeg rau zaub mov, cias muab tus sau ntawd yuav lub npe ntawd directory. Li ntawd, Piv txwv, Yog hu ua cov directory “uploads”, koj saib nws los ntawm qhov chaw nyob http://taylorlopes.com/uploads.

Qhov teeb meem yog tias thaum teem tau WordPress (los yog lwm yam mob) nrog tus phooj ywg URL, Zoo li cas yog thaum muaj ib nplooj hu ua muaj mob muaj ib qhov URL http://taylorlopes.com/?page_id = 2, yuav ib yam dab tsi zoo li http://taylorlopes.com/contatos. Nco ntsoov tias qhov tshiab uas tsis muaj qhov URL (Tus phooj ywg DITA), Nws tsa hu txog tus directory, thaum uas muaj mob yeej yog tsis ib directory, xwb, tab sis ib sab.

Tsis ntev, txij lub caij koj yuav txiav txim seb yuav siv tus phooj ywg URL yog tsis kos ib directory, vim WordPress interprets no li hu rau ib sab, uas obviously tsis nyob ua ib ke, thiab throws qhov yuam kev “OPS! Nplooj ntawv no ua tsis tau nyob“. Li ntawd, Yuav ua li cas rau kos ib directory tsis tas cov WordPress txhais tham muaj tshwm rau ib sab?

Tov

Mus daws cov teebmeem no thiab yuav tau ncaj qha mus saib tau ib directory hauv lub hauv paus hniav ntawm tus neeg rau zaub mov los tsis muaj tus WordPress txhais nws ua ib sab, Qhib cov ntaub ntawv .htaccess thiab ntxiv cov nram qab no txoj kab hauv qab no tus thawj tsab ntawv RewriteRule, hloov “MyDir” lub npe koj tam sim no directory:

Chaws ib nrab

RewriteCond %{REQUEST_URI} !^/(MyDir|MyDir/.*)$

Teb chaws

# PIB WordPress
<IfModule mod_rewrite.(c)>
Rewriteengine hauv RewriteBase /
RewriteRule ^ Performance index yog muaj.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(MyDir|MyDir/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.PHP [L]
</IfModule>
# END WordPress

Ceeb toom:

Tus .htaccess fica na raiz do diretório onde o conteúdo Web é publicado, como por exemplo no diretório /www (wampserver) ou no /htdocs (xampp).

Redirecionamento

A ideia aqui é fazer com que um Post (página) responda por duas URL amigáveis, desta forma, quando alguém digitar http://taylorlopes.com/about (a página about não existe) seja feito um redirecionamento para http://taylorlopes.com/sobre (página sobre existe). Siv lub .htaccess para fazer o redirecionamento:

Chaws ib nrab

Redirect /about /sobre

Teb chaws

# PIB WordPress
<IfModule mod_rewrite.(c)>
Rewriteengine hauv RewriteBase /
RewriteRule ^ Performance index yog muaj.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(util|util/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Redirect /about /sobre
RewriteRule . /index.PHP [L]
</IfModule>
# END WordPress

Tau qhov twg los

WordPress: Exclude directory from URL rewrite with .htaccess

Tag nrho hits: 7829

sau ntawv cia

Qhov koj email chaw nyob yuav tsis muab luam tawm. Search yog cim muaj *