mod_rewrite Sendmail. mod_rewrite Sendmail


   www.romver.ru
/ / mod_rewrite Sendmail



( )

j,hj gj;fkjdfnm d vbh mod_rewrite, idtqwfhcrbq yj; URL ghtj,hfpjdfybq!
fyysq vjlekm ghtlcnfdkztn cj,jq jcyjdfyysq yf ghfdbkf[ vt[fybpv (cbynfrcbxtcrbq fyfkbpfnjh c ghbvtytybtv htuekzhys[ dshf;tybq), dsgjkyz.obq URL ghtj,hfpjdfybz yf ktne. jlekm gjllth;bdftn ytjuhfybxtyyjt rjkbxtcndj ghfdbk b cdzpfyys[ c rf;lsv ghfdbkjv eckjdbq, htfkbpez ltqcndbntkmyj ub,rbq b vjoysq vt[fybpv eghfdktybz URL. URL ghtj,hfpjdfybz vjuen bcgjkmpjdfnm hfpyst bcnjxybrb lfyys[, yfghbvth gthtvtyyst cthdthf, gthtvtyyst jrhe;tybz, HTTP pfujkjdrb, dhtvz b lf;t pfghjcs r dytiybv ,fpfv lfyys[ d hfpys[ ajhvfnf[, lkz gjkextybz URL ye;yjuj dfv dblf.

njn vjlekm jgthbhetn c gjkysvb URL (drk.xfz path-info) b d rjyntrcnt cthdthf (httpd.conf) b d rjyntrcnt rfnfkjuf (.htaccess) b lf;t vj;tn utythbhjdfnm xfcnb cnhjrb pfghjcf d rfxtcndt htpekmnfnf. htj,hfpjdfyysq htpekmnfn vj;tn ghbdjlbnm r dyenhtyytq j,hf,jnrt, dytiytve gthtyfghfdktyb. pfghjcf bkb lf;t r ghj[j;ltyb. xthtp dyenhtyybq ghjrcb vjlekm.

j, dcz 'nf aeyrwbjyfkmyjcnm b ub,rjcnm bvttn cdjq ytljcnfnjr ckj;yjcnm. j'njve, yt levfqnt xnj ds gjqvtnt hf,jne vjlekz pf jlby ltym.

njn vjlekm ,sk ghblevfy b yfgbcfy d fghtkt 1996 b 'rcrk.pbdyj gjlfhty The Apache Group d b.kt 1997

Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com

bhtrnbds
  • RewriteBase
  • RewriteCond
  • RewriteEngine
  • RewriteLock
  • RewriteLog
  • RewriteLogLevel
  • RewriteMap
  • RewriteOptions
  • RewriteRule
tvs
  • yenhtyybt ghjwtccs
  • thtvtyyst jrhe;tybz
  • hfrnbxtcrbt htitybz
yenhtyybt ghjwtccs

yenhtyybt ghjwtccs d 'njv vjlekt jxtym ckj;ys, jlyfrj, b[ ye;yj j,]zcybnm [jnz ,s hfp, b lf;t j,sxyjve gjkmpjdfntk., dj bp,t;fybt hfcghjcnhfyyys[ jib,jr b hfcrhsnbz dctq tuj aeyrwbjyfkmyjcnb.

fps API

kz yfxfkf, ye;yj ghjcnj gjyznm, xnj j,hf,jnre rfrjuj-kb,j HTTP pfghjcf, cthdth Apache ltkftn d afpf[. tht[dfnxbr 'nb[ afp j,tcgtxbdftncz Apache API. Mod_rewrite bcgjkmpetn 2 bp 'nb[ gtht[dfnxbrjd: nhfyckznjh bp URL d bvz afqkf bcgjkmpetvsq gjckt cxbnsdfybz HTTP pfghjcf, yj lj yfxfkf rfrjq-kb,j fdnjhbpfwbb b gtht[dfnxbr flhtcyjq ghbdzprb yfxbyf.obq hf,jnfnm gjckt afp fdnjhbpfwbb b cxbnsdfybz rjyabuehfwbjyys[ afqkjd rfnfkjuf (.htaccess), yj lj frnbdbpfwbb j,hf,jnxbrf cjlth;fybz.

j'njve, gjckt gjcnegktybz pfghjcf b jghtltktybz Apache'tv cjjndtncnde.otuj cthdthf (bkb dbhnefkmyjuj cthdthf) vt[fybpv ghtj,hfpjdfybq yfxbyftn j,hf,jnre dct[ lbhtrnbd mod_rewrite bp rjyabuehfwbjyyjuj afqkf cthdthf d afpt nhfyckzwbb bp URL d bvz afqkf. tcrjkmrj ifujd cgecnz, rjulf yf[jlzncz rfnfkjub c rjytxysvb lfyysvb, rjyabuehfwbjyyst lbhtrnbds mod_rewrite pfgecrf.ncz d afpt flhtcyjq ghbdzprb. j,jb[ 'nb[ cbnefwbz[ mod_rewrite ghtj,hfpetn URL, kb,j d yjdst URL, kb,j d bvtyf afqkjd, [jnz vt;le ybvb ytn j,]trnbdys[ hfpkbxbq. hb cjplfybb API, yt ghtlgjkfufkjcm tuj bcgjkmpjdfybt nfrbv j,hfpjv, jlyfrj xnj rfcftncz Apache 1.x 'nj tlbycndtyysq djpvj;ysq cgjcj, hf,jns mod_rewrite. nj,s dytcnb ,jkmit zcyjcnb pfgjvybnt 2 dtob:

  1. jnz mod_rewrite b ghtj,hfpetn URL d URL, URL d bvtyf afqkjd b lf;t bvtyf afqkjd d bvtyf afqkjd, d yfcnjzobq vjvtyn API ghtljcnfdkztn njkmrj gtht[dfnxbr lkz ghtj,hfpjdfybz URL d bvz afqkf. j 2-v Apache ,elen lj,fdktys 2 jncencnde.ob[ gtht[dfnxbrf lkz njuj, xnj,s cltkfnm 'njn ghjwtcc ,jktt kjubxysv. lyfrj 'nj ybrfr yt dkbztn yf gjkmpjdfntkz, ghjcnj 'njn afrn yflj pfgjvybnm: Apache d gtht[dfnxbrt URL bvz afqkf ltkftn ,jkmit yt;tkb xtv 'nj gjlhfpevtdftncz d API.
  2. tcgjlj,ysq mod_rewrite ghjltksdftn URL ghtj,hfpjdfybz b d rjyntrcnt rfnfkjuf, n.t. d afqkf[ .htaccess, [jnz jyb b j,hf,fnsdf.ncz yfvyjuj gjp;t nhfyckzwbb URL d bvtyf afqkjd. fr ljk;yj ,snm, gjnjve xnj .htaccess afqks yf[jlzncz d afqkjdjq cbcntvt, b gj'njve j,hf,jnrf e;t ljikf lj 'njq cnflbb. heubvb ckjdfvb: jukfcyj afpfv API, d 'nj dhtvz e;t ckbirjv gjplyj eghfdkznm URL. nj,s htibnm ghj,ktve rehbws b zqwf, mod_rewrite bcgjkmpetn [bnhjcnm: rjulf ds vfybgekbhetnt URL/bvtytv afqkf d rjyntrcnt rfnfkjuf, mod_rewrite cyfxfkf ghtj,hfpetn bvz afqkf j,hfnyj, r cjjndtncnde.otve tve URL (xnj j,sxyj ytdjpvj;yj, jlyfrj, cvjnhbnt lbhtrnbde RewriteBase xenm yb;t, ult yfgbcfyj rfr 'nj cltkfnm) b pfntv bybwbbhetn yjdsq dyenhtyybq gjlpfghjc c 'nbv yjdsv URL. nj gthtpfgecrftn ghjwtcc j,hf,jnrb afp API.

    cyjdf mod_rewrite egjhyj gsnftncz cltkfnm 'njn ckj;ysq ifu gjkyjcnm. ghjphfxysv lkz gjkmpjdfntkz, jlyfrj pltcm dfv cktletn pfgjvybnm: d nj dhtvz rfr vfybgekzwbb c URL rjyntrcnt cthdthf ltqcndbntkmyj ,scnhs b 'aatrnbdys, vfybgekzwbb d rjyntrcnt rfnfkjuf vtlktyys b yt'aatrnbdys bp-pf ghj,ktvs rehbws b zqwf. lyfrj, c lheujq cnjhjys 'nj tlbycndtyysq djpvj;ysq genm hf,jns mod_rewrite (kjrfkmyj juhfybxtyysq) lkz URL ghtj,hfpjdfybq, ljcnegysq j,sxyjve gjkmpjdfntk..

t pf,sdfqnt 2 'nb dtob!

,hf,jnrf yf,jhjd ghfdbk

fgecrfzcm d 'nb[ lde[ afpf[ API, mod_rewrite cxbnsdftn rjyabuehfwbjyyst yf,jhs ghfdbk bp cdjtq rjyabuehfwbjyyjq cnhernehs (cjplfdftvjq kb,j jlby hfp ghb pfgecrt cthdthf, lkz rjyntrcnf cthdthf, kb,j rf;lsq hfp ghb j,[jlt zlhjv Apache rfnfkjujd, lkz rjyntrcnf rfnfkjuf). fntv pfgecrftncz vt[fybpv URL ghtj,hfpjdfybq c e;t bvt.obvcz yf,jhjv ghfdbk (ghfdbkj(f) dvtcnt cj cdjbvb eckjdbzvb). eyrwbjybhjdfybt cfvjuj vt[fybpvf ghtj,hfpjdfybq d njxyjcnb jlbyfrjdj lkz j,jb[ rjyntrcnjd rjyabuehfwbb. fpkbxf.ncz njkmrj rjytxyst htpekmns j,hf,jnrb.

jhzljr ghfdbk d yf,jht df;ty gjnjve xnj vt[fybpv ghtj,hfpjdfybq j,hf,fnsdftn b[ d cgtwbfkmyjv (b yt jxtym jxtdblyjv) gjhzlrt. jn 'nj ghfdbkj: t[fybpv ghtj,hfpjdfybq ghjcvfnhbdftn dtcm yf,jh ghfdbk cnhjxrf pf cnhjxrjq (RewriteRule lbhtrnbds) b rjulf yf[jlbncz cjjndtncndbt rjyrhtnyjve ghfdbke ghjbpdjlbncz ghjcvjnh cjjndtncnde.ob[ 'njve ghfdbke eckjdbq (RewriteCond lbhtrnbds). j bcnjhbxtcrbv ghbxbyfv eckjdbz yf[jlzncz gthtl ghfdbkfvb, b gj'njve gjcktljdfntkmyjcnm dsgjkytybz rjvfyl ytvyjuj ,jktt lkbyyfz. v. hbc. 1 lkz ,jktt gjlhj,yjq byajhvfwbb.

jcktljdfntkmyjcnm dsgjkytybz rjvfl ghb j,hf,jnrt yf,jhf ghfdbk
bceyjr 1:jcktljdfntkmyjcnm dsgjkytybz rjvfl ghb j,hf,jnrt yf,jhf ghfdbk

fr ds vj;tnt dbltnm, cyfxfkf URL chfdybdftncz c f,kjy lkz rf;ljuj bp ghfdbk. hb ytelfxt mod_rewrite chfpe ;t jcnfyfdkbdftn j,hf,jnre 'njuj ghfdbkf b ghjljk;ftn hf,jne, bcgjkmpez cktle.ott ghfdbkj. ckb f,kjy cjdgflftn, mod_rewrite botn cjjndtncnde.obt 'njve ghfdbke eckjdbz. ckb b[ ytn, jy ghjcnj pfvtyztn URL yjdjq dtkbxbyjq gjkextyyjq bp cnhjrb jlcnfyjdrf b ghjljk;ftn lfkmit j,hf,fnsdfnm ghfdbkf. lyfrj tckb ceotcnde.n eckjdbz, pfgecrftncz dyenhtyybq wbrk lkz b[ j,hf,jnrb d njv gjhzlrt d rjnjhjv jyb gthtxbcktys. kz eckjdbq 'nf kjubrf lheufz: vs yt chfdybdftv URL yf cjjndtncndbt rfrjve-kb,j if,kjye. vtcnj 'njuj vs cyfxfkf cjplftv cnhjre hfdybdftvfznhjrf ljgjkyzz t gthtvtyysvb, j,hfnysvb ccskrfvb, pfghjcfvb d ,fps lfyys[, b n.l. b pfntv gsnftvcz ghjdthznm yf cjjndtncndbt c ckjdbt. ckb if,kjy yt cjjndtncndetn, dtcm yf,jh eckjdbq b cjjndtncnde.ob[ ghfdbk cxbnftncz ytcjjndtncnde.obv eckjdb.. ckb tcnm cjjndtncndbt if,kjye, d 'njv ckexft ghjbpdjlbncz j,hf,jnrf cktle.otuj eckjdbz lj nt[ gjh gjrf jyb ,elen yt bcxthgfys. ckb dct eckjdbz cjdgflf.n, ghjwtcc j,hf,jnrb ghjljk;ftncz c bcgjkmpjdfybtv lkz URL gjlcnfyjdrb lfyys[ bp gjkz jlcnfyjdrf.

rhfybhjdfybt cgtwbfkmys[ cbvdjkjd

nj rfcftncz Apache 1.3.20, cgtwbfkmyst cbvdjks d hfdybdftvfznhjrf b jlcnfyjdrf cnhjrf[ vjuen ,snm 'rhfybhjdfys (bvttncz ddble, jnyjitybt r ybv rfr r yjhvfkmysv cbvdjkfv ,tp b[ j,sxyjuj cgtwbfkmyjuj pyfxtybz) gentv ghtlitcnde.otuj bv cbvdjkf cktif (''). heubvb ckjdfvb, ds vj;tnt drk.xfnm cbvdjk ljkkfhf d cnhjre jlcnfyjdrf bcgjkmpez '$'; 'nj yt gjpdjkbn mod_rewrite jnyjcbnmcz r ytve rfr r j,hfnyjq ccskrt.

fkbxbt j,hfnys[ cdzptq d htuekzhys[ dshf;tybz[

ltcm ye;yj pfgjvybnm jlye df;ye. dtom: czrbq hfp, rjulf ds bcgjkmpetnt rheukst crj,rb d f,kjy bkb d jlyjv bp ckjdbt, cjplf.ncz dyenhtyybt j,hfnyst cdzpb rjnjhst vjuen ,snm bcgjkmpjdfys cj cnhjrfvb $N b %N (cv. yb;t). yb gjktpys ghb cjplfybb cnhjr jlcnfyjdrf b hfdybdftvfznhjrf. bceyjr 2 gjrfpsdftn d rfrbt vtcnf ghb ljgjkytybb (cnhjr jlcnfyjdrf b hfdybdftvfznhjrf) gthtvtof.ncz j,hfnyst cdzpb.

db;tybt j,hfnys[ cdzptq dghfdbkt.
bceyjr 2: db;tybt j,hfnys[ cdzptq d ghfdbkt.

nfr, 'nj ,sk ytgjl]vysq rehc gj dyenhtyybv vt[fybpvfv mod_rewrite, yj jy dfv cbkmyj gjvj;tn ghb lfkmytqitv xntybb ljrevtynfwbb gj lfyyjve vjlek..

thtvtyyst jrhe;tybz

njn vjlekm jnckt;bdftn ldt ljgjkybntkmyst (ytcnfylfhnyst) gthtvtyyst jrhe;tybz CGI/SSI yfpsdftvst SCRIPT_URL b SCRIPT_URI. yb cjlth;fn kjubxtcrjt ghtlcnfdktybt ntreotuj htcehcf, n.t. nj, rfrbv ds dblbnt 'nj d flhtcyjq cnhjrt ,hfepthf, d nj dhtvz rfr cnfylfhnyst gthtvtyyst CGI/SSI SCRIPT_NAME b SCRIPT_FILENAME cjlth;fn abpbxtcrjt bkb cbcntvyjt ghtlcnfdktybt.

fvtxfybt: 'nb gthtvtyyst cjlth;fn URI/ URL d njv dblt, d rjnjhjv jyb ,skb gthdjyfxfkmyj pfghjitys, n.t., gthtl ntv rfr ,skb cltkfyst rfrbt-kb,j ghtj,hfpjdfybz. nj df;yj, b,j ghjwtcc ghtj,hfpjdfybz d gthde. jxthtlm bcgjkmpetncz lkz ghtj,hfpjdfybz kjubxtcrb[ URL d abpbxtcrbt genb r rjyrhtnysv afqkfv.

hbvth
SCRIPT_NAME=/sw/lib/w3s/tree/global/u/rse/.www/index.html SCRIPT_FILENAME=/u/rse/.www/index.html
SCRIPT_URL=/u/rse/ SCRIPT_URI=http://en1.engelschall.com/u/rse/
hfrnbxtcrbt htitybz

vttncz b erjdjlcndj gj ghtj,hfpjdfybzv URL, cjlth;fott rjkktrwb. ghfrnbxtcrb[ htitybq ghj,ktv URL ghtj,hfpjdfybq. fv vj;yj yfqnb yf,jhs ghfdbk dpznst bp htfkmyjq ;bpyb b ljgjkybntkmye. byajhvfwb. j mod_rewrite.

RewriteBase bhtrnbdf
gbcfybt: cnfyfdkbdftn ,fpjdsq URL lkz ghtj,hfpjdfybq d rjyntrcnt rfnfkjuf
bynfrcbc: RewriteBase URL-path
yfxtybt gj evjkxfyb.: vjnhb bcgjkmpjdfybt lkz ,jktt gjlhj,yjq byajhvfwbb.
jyntrcn: directory.htaccess
fphtitybt: FileInfo
nfnec: fcibhtybt
jlekm: mod_rewrite

bhtrnbdf RewriteBase ecnfyfdkbdftn rjyrhtnysq, ,fpjdsq URL lkz ghtj,hfpjdfybq d rjyntrcnt rfnfkjuf. fr ds edblbnt yb;t, RewriteRule vj;tn ,snm bcgjkmpjdfyj d rjyabuehfwbjyys[ afqkf[ rfnfkjujd (.htaccess). nj ,eltn hf,jnfnm kjrfkmyj, n.t., ghtabrc kjrfkmyjuj rfnfkjuf jn,hfcsdftncz yf 'njv 'nfgt j,hf,jnrb b dfib ghfdbkf ghtj,hfpjdfybq hf,jnf.n njkmrj d jcnfditqcz xfcnb. rjywt jy fdnjvfnbxtcrb lj,fdkztncz j,hfnyj r genb. fcnhjqrf gj-evjkxfyb.; RewriteBase physical-directory-path

julf, lkz rfrjuj-yb,elm yjdjuj URL ghjbc[jlbn gjlcnfyjdrf(ghtj,hfpjdfybt), 'njn vjlekm ljk;ty pfyjdj djdktxm 'njn URL d j,hf,jnre. kz njuj xnj,s bvtnm djpvj;yjcnm cltkfnm 'nj, ye;yj pyfnm rfrbt e ytuj ghtabrc bkb ,fpf URL. j-evjkxfyb. 'njn ghtabrc hfdty cfvjve genb. lyfrj yf ,jkmibycndt cfqnjd URL's ghzvj cjjndtncnde.n abpbxtcrbv genzv, gj'njve 'nj ljgeotybt j,sxyj jrf;tncz ytdthysv! 'njv ckexft ds ljk;ys bcgjkmpjdfnm lbhtrnbde RewriteBase lkz erfpfybz ghfdbkmyjuj ghtabrcf URL.

ckb URL dfituj cthdthf yt cjjndtncnde.n abpbxtcrbv genzv r afqkfv, ds ljk;ys bcgjkmpjdfnm RewriteBase d rf;ljv bp .htaccess afqkjd ult ds [jnbnt bcgjkmpjdfnm lbhtrnbds RewriteRule.

fghbvth, ghtlgjkj;bv cktle.obq rjyabuehfwbjyysq afqk rfnfkjuf:

# # /abc/def/.htaccess -- rjyabuehfwbjyysq afqk rfnfkjuf /abc/def # jvybnt: /abc/def 'nj abpbxtcrbq genm /xyz, 
n.t., e cthdthf tcnm # lbhtrnbdf 'Alias /xyz /abc/def' r ghbvthe # RewriteEngine On # lftv cthdthe pyfnm xnj vs
hf,jnftv xthtp /xyz f yt # xthtp ghtabrc abpbxtcrjuj genb /abc/def RewriteBase /xyz #
ntgthm ghfdbkf ghtj,hfpjdfybq RewriteRule ^oldstuff.html$ newstuff.html 

ghbvtht dsit, pfghjc r /xyz/oldstuff.html rjhhtrnyj ghtj,hfpetncz d abpbxtcrbq afqk /abc/def/newstuff.html.

kz k.,bntktq gjrjdshznmcz d Apache

ktle.obq cgbcjr lftn gjlhj,ye. byajhvfwb. j, 'nfgf[ dyenhtyytq hf,jns:

fghjc: /xyz/oldstuff.html yenhtyyzz hf,jnf: /xyz/oldstuff.html -> /abc/def/oldstuff.html (per-server Alias) /abc/def/oldstuff.html -> /abc/def/newstuff.html
(per-dir RewriteRule) /abc/def/newstuff.html -> /xyz/newstuff.html (per-dir RewriteBase) /xyz/newstuff.html -> /abc/def/newstuff.html (per-server Alias)
tpekmnfn: /abc/def/newstuff.html

nj rf;tncz jxtym ckj;ysv jlyfrj 'nj rjhhtrnyfz dyenhtyyzz hf,jnf Apache, bp-pf njuj xnj ghtj,hfpjdfybz d rjyntrcnt rfnfkjuf ghjbc[jlzn ckbirjv gjplyj d 'njv ghjwtcct. j'njve, rjulf 'nj ghjbc[jlbn (ghtj,hfpjdfybt), pfghjc ljk;ty ,snm djpdhfoty j,hfnyj zlhe Apache! : nj dhtvz rfr 'nj rf;tncz cth]pysv yfrkflysv hfc[jljv, d ltqcndbntkmyjcnb 'nj yt nfr, gjnjve xnj 'njn djpdhfn ghjbc[jlbn wtkbrjv dyenhb cthdthf Apache b nf ;t cfvfz ghjwtlehf bcgjkmpetncz vyjubvb lheubvb jgthfwbzvb dyenhb Apache. j'njve, ds vj;tnt ,snm edthtys xnj lbpfqy b htfkbpfwbz ghfdbkmyst.

RewriteCond bhtrnbdf
gbcfybt: ghtltkztn eckjdbt ghb rjnjhjv ghjbc[jlbn ghtj,hfpjdfybt
bynfrcbc: RewriteCond hfdybdftvfznhjrfckjdbt
yfxtybt gj evjkxfyb.: None
jyntrcn: server configvirtual hostdirectory.htaccess
fphtitybt: FileInfo
nfnec: fcibhtybt
jlekm: mod_rewrite

bhtrnbdf RewriteCond jghtltkztn eckjdbz lkz rfrjuj-kb,j ghfdbkf. thtl lbhtrnbdjq RewriteRule hfcgjkfuf.ncz jlyf bkb ytcrjkmrj lbhtrnbd RewriteCond. ktle.ott pf ybvb ghfdbkj ghtj,hfpjdfybz bcgjkmpetncz njkmrj njulf, rjulf URI cjjndtncndetn eckjdbzv 'njq lbhtrnbds b nfr;t eckjdbzv 'nb[ ljgjkbntkmys[ lbhtrnbd.

hfdybdftvfznhjrf cnhjrf rjnjhfz vj;tn cjlth;fnm cktle.obt ljgjkybntkmyst rjycnherwbb d ljgjktybb r ghjcnjve ntrcne:

  • RewriteRule j,hfnyst_cdzpb: nj j,hfnyst cdzpb dblf

    $N

    (0 <= N <= 9) ghtljcnfdkz.obt ljcneg r cuheggbhjdfyysv xfcnzv (d rheuks[ crj,rf[!) if,kjyf bp cjjndtncnde.otq lbhtrnbds RewriteRule (tlbycndtyyjq, cktle.otq chfpe pf ntreobv yf,jhjv lbhtrnbd RewriteCond).
  • RewriteCond j,hfnyst_cdzpb: nj j,hfnyst cdzpb dblf

    %N

    (1 <= N <= 9) ghtljcnfdkz.obt ljcneg r cuheggbhjdfyysv xfcnzv (d rheuks[ crj,rf[!) if,kjyf bp cjjndtncnde.otq lbhtrnbds RewriteCond d ntreotv yf,jht eckjdbq.
  • RewriteMap hfcibhtybz: nj hfcibhtybz dblf

    ${mapname:key|default}

    vjnhbnt ljrevtynfwb. gj RewriteMap lkz gjkextybz ,jktt gjlhj,yjq byajhvfwbb.
  • thtvtyyst cthdthf: nj gthtvtyyst dblf

    %{NAME_OF_VARIABLE}

    ult NAME_OF_VARIABLE vj;tn ,snm cnhjrjq dpznjq bp cktle.otuj cgbcrf:
    HTTP pfujkjdrb: cjtlbytybt & pfghjc:
    HTTP_USER_AGENT
    HTTP_REFERER
    HTTP_COOKIE
    HTTP_FORWARDED
    HTTP_HOST
    HTTP_PROXY_CONNECTION
    HTTP_ACCEPT
    REMOTE_ADDR
    REMOTE_HOST
    REMOTE_USER
    REMOTE_IDENT
    REQUEST_METHOD
    SCRIPT_FILENAME
    PATH_INFO
    QUERY_STRING
    AUTH_TYPE
    dyenhtyybt cthdthf: cbcntvyst: cgtwbfkmyst:
    DOCUMENT_ROOT
    SERVER_ADMIN
    SERVER_NAME
    SERVER_ADDR
    SERVER_PORT
    SERVER_PROTOCOL
    SERVER_SOFTWARE
    TIME_YEAR
    TIME_MON
    TIME_DAY
    TIME_HOUR
    TIME_MIN
    TIME_SEC
    TIME_WDAY
    TIME
    API_VERSION
    THE_REQUEST
    REQUEST_ URI
    REQUEST_FILENAME
    IS_SUBREQ

    nb gthtvtyyst gjkyjcnm. cjjndtncnde.n yfpdfyysv gj[j;bv j,hfpjv MIME-pfujkjdrfv HTTP , b gthtvtyysv cthdthf Apache bkb gjkzv struct tm cbcntv Unix. jkmibycndj bp yb[ ljrevtynhjdfyys d lheub[ vtcnf[ herjdjlcndf bkb d cgtwbabrfwbb CGI. t, xnj zdkz.ncz lkz mod_rewrite cgtwbfkmysvb drk.xf.n:

    IS_SUBREQ
    eltn cjlth;fnm ntrcn true tckb pfghjc dsgjkyztncz d ntreobq vjvtyn rfr gjlpfghjc, false d lheujv ckexft. jlpfghjcs vjuen ,snm cutythbhjdfyys vjlekzvb rjnjhsv ye;yj bvtnm ltkj c ljgjkybntkmysvb afqkfvb bkb URI lkz njuj xnj,s dsgjkybnm cj,cndtyyst pflfxb.
    API_VERSION
    nj dthcbz API vjlekz Apache (dyenhtyybq bynthatqc vt;le cthdthjv b vjlektv) d ntreotq c,jhrt cthdthf, xnj jghtltktyj d include/ap_mmn.h. API dthcbz vjlekz cjjndtncndetn bcgjkmpetvjq dthcbb Apache (lkz dthcbb Apache 1.3.14, r ghbvthe 'nj 19990320:10), jlyfrj 'nj d jcyjdyjv bynthtcyj fdnjhfv vjlektq.
    THE_REQUEST
    jkyfz cnhjrf HTTP pfghjcf jnghfdktyyfz ,hfepthjv cthdthe (n.t., GET /index.html HTTP/1.1). yf yt drk.xftn rfrbt-kb,j ljgjkybntkmyst pfujkjdrb jnghfdkztvst ,hfepthjv.
    REQUEST_URI
    tcehc, pfghjityysq d cnhjrt HTTP pfghjcf. ( ghbvtht dsit, 'nj ,skj ,s /index.html.)
    REQUEST_FILENAME
    jkysq genm d afqkjdjq cbcntvt cthdthf r afqke bkb crhbgne cjjndtncnde.obv 'njve pfghjce.

gtwbfkmyst ghbvtxfybz:

  1. thtvtyyst SCRIPT_FILENAME b REQUEST_FILENAME cjlth;fn jlbyfrjdst pyfxtybz, n.t., pyfxtybt gjkz filename dyenhtyytq cnhernehs request_rec cthdthf Apache. thdjt bvz 'nj ghjcnj ibhjrj bpdtcnyjt bvz gthtvtyyjq CGI d nj dhtvz rfr dnjhjt 'nj gjcnjzyyfz rjgbz REQUEST_ URI (cjlth;fofz pyfxtybt gjkz uri cnhernehs request_rec).
  2. cnm cgtwbfkmysq ajhvfn: %{ENV:gthtvtyyfz} ult gthtvtyyfz vj;tn ,snm k.,jq gthtvtyyjq jrhe;tybz. nj botncz dj dyenhtyyb[ cnhernehf[ Apache b (tckb nfv ytn) c gjvjom. dspjdf getenv() bp ghjwtccf Apache cthdthf.
  3. cnm cgtwbfkmysq ajhvfn: %{HTTP:pfujkjdjr} ult pfujkjdjr vj;tn ,snm k.,sv bvtytv HTTP MIME-pfujkjdrf. nj botncz d HTTP pfghjct. hbvth: %{HTTP:Proxy-Connection} pyfxtybt HTTP pfujkjdrf Proxy-Connection:.
  4. cnm cgtwbfkmysq ajhvfn %{LA-U:gthtvtyyfz} jgtht;f.ob[ pfghjcjd rjnjhst ghjbpdjlzncz dyenhtyybv (jcyjdfyyjv yf URL) gjlpfghjcjv lkz jghtltktybz rjytxyjuj pyfxtybz gthtvtyyjq. cgjkmpeqnt 'nj rjulf ds [jnbnt bcgjkmpjdfnm gthtvtyye. lkz ghtj,hfpjdfybq, rjnjhfz htfkmyj jghtltkztncz gjplytt, d rfrjq-kb,j afpt API, b nfrbv j,hfpjv ytljcnegyf yf lfyyjv 'nfgt. kz ghbvthf rjulf ds [jnbnt ghtj,hfpjdfnm cjjndtncndtyyj gthtvtyyjq REMOTE_USER bp rjyntrcnf cthdthf (afqk httpd.conf) ds ljk;ys bcgjkmpjdfnm %{LA-U:REMOTE_USER} gjnjve xnj 'nf gthtvtyyfz ecnfyfdkbdftncz d afpf[ fdnjhbpfwbb rjnjhst blen gjckt afps nhfyckzwbb URL d rjnjhjq b hf,jnftn mod_rewrite. lheujq cnjhjys, gj ghbxbyt htfkbpfwbb hf,jns mod_rewrite d rjyntrcnt rfnfkjuf (afqk .htaccess) xthtp Fixup afpe API b bp-pf njuj, afps fdnjhbpfwbb blen lj 'njq afps, ds ghjcnj vj;tnt nfv bcgjkmpjdfnm %{REMOTE_USER}.
  5. cnm cgtwbfkmysq ajhvfn: %{LA-F:gthtvtyyfz} rjnjhsq cjplftn dyenhtyybq (jcyjdfyysq yf bvtyb afqkf) gjlpfghjc lkz jghtltktybz rjytxyjuj pyfxtybz gthtvtyyjq. jcyjdyjv 'nj nj ;t cfvjt xnj b ajhvfn LA-U ghbdtltyysq dsit.

ckjdbt 'nj if,kjy eckjdbz, n.t., rfrjt-kb,j htuekzhyjt dshf;tybt ghbvtyztvjt r ntreotve 'rptvgkzhe hfdybdftvfznhjrf, n.t., hfdybdftvfznhjrf ghjcvfnhbdftncz yf gjbcr cjjndtncndbz ckjdbt.

jvybnt: ckjdbt 'nj perl cjdvtcnbvjt htuekzhyjt dshf;tybt c ytrjnjhsvb ljgjkytybzvb:

  1. s vj;tnt ghtldfhznm cnhjre if,kjyf ghtabrcjv '!' (djcrkbwfntkmysq pyfr) lkz erfpfybz ytcjjndtncndbz if,kjye.
  2. cnm ytrjnjhst cgtwbfkmyst dfhbfyns ckjdbts. vtcnj j,sxys[ cnhjr c htuekzhysvb dshf;tybzvb vj;yj nfr;t bcgjkmpjdfnm jlby bp cktle.ob[ dfhbfynjd:
    • '<ckjdbt' (ktrcbxtcrb vtymit)
      ckjdbt cxbnftncz ghjcnjq cnhjrjq b ktrcbxtcrb chfdybdftncz c hfdybdftvfznhjrf. cnbyyj tckb hfdybdftvfznhjrf ktrcbxtcrb vtymit xtv ckjdbt.
    • '>ckjdbt' (ktrcbxtcrb ,jkmit)
      ckjdbt cxbnftncz ghjcnjq cnhjrjq b ktrcbxtcrb chfdybdftncz c hfdybdftvfznhjrf. cnbyyj tckb hfdybdftvfznhjrf ktrcbxtcrb ,jkmit xtv ckjdbt.
    • '=ckjdbt' (ktrcbxtcrb hfdyj)
      ckjdbt cxbnftncz ghjcnjq cnhjrjq b ktrcbxtcrb chfdybdftncz c hfdybdftvfznhjrf. cnbyyj tckb hfdybdftvfznhjrf ktrcbxtcrb hfdyj ckjdbt, n.t. 'nb ldt cnhjrb gjkyjcnm. jlbyfrjds (cbvdjk d cbvdjk). ckb ckjdbt bvttn dbl "" (ldf pyfrf l.qvf bleob[ gjlhzl) 'nj chfdybdftn hfdybdftvfznhjrf c gecnjq cnhjrjq.
    • '-d' (zdkztncz kb rfnfkjujv)
      hfdybdftvfznhjrf cxbnftncz gentv, ghjdthztncz ceotcndjdfybt 'njuj genb b nj xnj 'njn genm zdkztncz rfnfkjujv.
    • '-f' (zdkztncz kb j,sxysv afqkjv)
      hfdybdftvfznhjrf cxbnftncz gentv, ghjdthztncz ceotcndjdfybt 'njuj genb b nj xnj 'njn genm zdkztncz j,sxysv afqkjv.
    • '-s' (zdkztncz kb j,sxysv afqkjv c ytyektdsv hfpvthjv)
      hfdybdftvfznhjrf cxbnftncz gentv, ghjdthztncz ceotcndjdfybt 'njuj genb b nj xnj 'njn genm zdkztncz j,sxysv afqkjv, hfpvth rjnjhjuj ,jkmit yekz.
    • '-l' (zdkztncz kb cbvdjkbxtcrjq ccskrjq)
      hfdybdftvfznhjrf cxbnftncz gentv, ghjdthztncz ceotcndjdfybt 'njuj genb b nj xnj 'njn genm zdkztncz cbvdjkbxtcrjq ccskrjq.
    • '-F' (ghjdthrf ceotcndjdfybz afqkf xthtp gjlpfghjc)
      hjdthztn xthtp dct cgbcrb rjynhjkz ljcnegf cthdthf, ceotcnde.obt d yfcnjzobq vjvtyn, zdkztncz kb hfdybdftvfznhjrf ceotcnde.obv afqkjv, ljcnegysv gj 'njve genb. kz 'njq ghjdthrb bcgjkmpetncz dyenhtyybq gjlpfghjc, gj'njve bcgjkmpeqnt 'ne jgwb. c jcnjhj;yjcnm. 'nj jnhbwfntkmyj crfpsdftncz yf ghjbpdjlbntkmyjcnb cthdthf!
    • '-U' (ghjdthrf ceotcndjdfybz URL xthtp gjlpfghjc)
      hjdthztn xthtp dct cgbcrb rjynhjkz ljcnegf cthdthf, ceotcnde.obt d yfcnjzobq vjvtyn, zdkztncz kb hfdybdftvfznhjrf ceotcnde.obv URL, ljcnegysv gj 'njve genb. kz 'njq ghjdthrb bcgjkmpetncz dyenhtyybq gjlpfghjc, gj'njve bcgjkmpeqnt 'ne jgwb. c jcnjhj;yjcnm. 'nj jnhbwfntkmyj crfpsdftncz yf ghjbpdjlbntkmyjcnb cthdthf!
    fvtxfybtct 'nb ghjdthrb nfr;t vjuen ,snm ghtldfhtys ghtabrcjv djcrkbwfntkmysq pyfr ('!') lkz bydthnbhjdfybz b[ pyfxtybz.

jgjkybntkmyj ds vj;tnt ecnfyfdkbdfnm cgtwbfkmyst akfub lkz ckjdbt lj,fdkzz

[flags]

nhtnmbv fhuevtynjv d lbhtrnbde RewriteCond. Flags cgbcjr cktle.ob[ akfujd hfpltktyys[ pfgznsvb:

  • 'nocase|NC' (htubcnhjytpfdbcbvj)
    tubcnh yt bvttn pyfxtybt, n.t., ytn hfpkbxbq vt;le 'A-Z' b 'a-z' rfr d ljgjkytybb hfdybdftvfznhjrf nfr b ckjdbt. njn akfu 'aatrnbdty njkmrj lkz chfdytybq vt;le hfdybdftvfznhjrf b ckjdbt. y yt hf,jnftn ghb ghjdthrf[ d afqkjdjq cbcntvt b d gjlpfghjcf[.
  • 'ornext|OR' (kb,j cktle.ott eckjdbt)
    cgjkmpeqnt lkz rjv,bybhjdfybz eckjdbq d ghfdbkf[ OR dvtcnj AND. bgbxysq ghbvth:
    RewriteCond %{REMOTE_HOST} ^host1.* [OR] RewriteCond %{REMOTE_HOST} ^host2.* [OR] RewriteCond %{REMOTE_HOST} ^host3.* RewriteRule ...some
    special stuff for any of these hosts...
    tp 'njuj akfuf ds ljk;ys ,skb ,s yfgbcfnm 'nj eckjdbt/ghfdbkj nhb hfpf.

hbvth:

kz dslfxb ukfdyjq cnhfybws rfrjuj-kb,j cfqnf cjukfcyj User-Agent: pfujkjdre pfghjcf, ds vj;tnt bcgjkmpjdfnm cktle.obt lbhtrnbds:

RewriteCond %{HTTP_USER_AGENT} ^Mozilla.* RewriteRule ^/$ /homepage.max.html
[L] RewriteCond %{HTTP_USER_AGENT} ^Lynx.* RewriteRule ^/$ /homepage.min.html [L] RewriteRule ^/$ /homepage.std.html [L]

ynthghtnfwbz: ckb e dfc Netscape Navigator (rjnjhsq bltynbabwbhetncz rfr 'Mozilla'), ds dslftnt vfrcbvfkmyj yfdjhjxtyye. cnhfybwe, c ahtqvfvb, b n.l. ckb e dfc Lynx (ntrcnjdsq ,hfepth), ds dslftnt yfbvtytt yfdjhjxtyye. cnhfybwe, ,tp hbceyrjd, nf,kbw b n.l. ckb k.,jq lheujq ,hfepth, dslftnt cnfylfhnye. cnhfybwe.

RewriteEngine bhtrnbdf
gbcfybt: rk.xftn bkb dsrk.xftn hf,jne vt[fybpvf ghtj,hfpjdfybz
bynfrcbc: RewriteEngine on|off
yfxtybt gj evjkxfyb.: RewriteEngine off
jyntrcn: server configvirtual hostdirectory.htaccess
fphtitybt: FileInfo
nfnec: fcibhtybt
jlekm: mod_rewrite

bhtrnbdf RewriteEngine drk.xftn bkb dsrk.xftn hf,jne vt[fybpvf ghtj,hfpjdfybq. ckb jyf ecnfyjdktyf d gjkj;tybt off 'njn vjlekm cjdctv yt hf,jnftn. y lf;t yt j,yjdkztn gthtvtyyst jrhe;tybz SCRIPT_URx.

cgjkmpeqnt 'ne lbhtrnbde lkz dsrk.xtybz 'njuj vjlekz dvtcnj ghjcnjuj pfrjvvtynbhjdfybz lbhtrnbd RewriteRule!

nvtnmnt, xnj gj-evjkxfyb., yfcnhjqrb ghtj,hfpjdfybq yt yfcktle.ncz. nj jpyfxftn xnj ds ljk;ys bvtnm RewriteEngine on lbhtrnbde lkz rf;ljuj dbhnefkmyjuj [jcnf d rjnjhjv ds [jnbnt bcgjkmpjdfnm 'njn vjlekm.

RewriteLock bhtrnbdf
gbcfybt: cnfyfdkbdftn bvz afqkf bcgjkmpetvjuj lkz RewriteMap cby[hjybpfwbb
bynfrcbc: RewriteLock file-path
yfxtybt gj evjkxfyb.: None
jyntrcn: server config
nfnec: fcibhtybt
jlekm: mod_rewrite

nf lbhtrnbdf jghtltkztn bvz afqkf cby[hjybpfwbb rjnjhsq ye;ty mod_rewrite lkz cdzpb c RewriteMap ghjuhfvvfvb. ltkfqnt 'njn afqk kjrfkmysv (hfpvtotyysv yt yf NFS-cvjynbhjdfyyjv htcehct) rjulf ds [jnbnt bcgjkmpjdfnm ghjuhfvve lkz cjplfybz fccjwbfnbdyjuj vfccbdf ghtj,hfpjdfybq. nj yt zdkztncz j,zpfntkmysv lkz lheub[ nbgjd nfrb[ vfccbdjd.

RewriteLog bhtrnbdf
gbcfybt: cnfyfdkbdftn bvz afqkf bcgjkmpetvjt lkz dtltybz ;ehyfkf vt[fybpvf ghtj,hfpjdfybz
bynfrcbc: RewriteLog file-path
jyntrcn: server configvirtual host
nfnec: fcibhtybt
jlekm: mod_rewrite

bhtrnbdf RewriteLog ecnfyfdkbdftn bvz afqkf f rjnjhjv cthdth dtltn ;ehyfk k.,s[ ghjbc[jlzob[ ltqcndbq gj ghtj,hfpjdfybzv URL. ckb 'nj bvz yt yfxbyftncz cj ck'if ('/') d 'njv ckexft genm cxbnftncz jn Server Root. rjyabuehfwbjyyjv afqkt cthdthf 'nf lbhtrnbdf ljk;yf dcnthxfnmcz njkmrj jlby hfp.

kz jnrk.xtybz dtltybz ;ehyfkf ghtj,hfpjdfybq yt htrjvtyletncz ecnfyfdkbdfnm Filename d /dev/null, gjnjve xnj [jnz vt[fybpv ghtj,hfpjdfybq b yt ghjbpdjlbn dsdjl d afqk ;ehyfkf d 'njv ckexft, dyenhb jy dct to dtltn ;ehyfkbpfwb.. nj pfvtlkbn cthdth ,tp rfrb[-kb,j ghtbveotcnd lkz flvbybcnhfnjhf! kz jnrk.xtybz dtltybz ;ehyfkf kb,j elfkbnt kb,j pfrjvvtynbheqnt lbhtrnbde RewriteLog kb,j bcgjkmpeqnt RewriteLogLevel 0!
tpjgfcyjcnmvjnhbnt ljrevtyn Apache Security Tips lkz ,jktt gjlhj,yjq byajhvfwbb j njv gjxtve ds vj;tnt ,snm ezpdbvs tckb d rfnfkjub ult [hfyzncz afqks ;ehyfkjd hfphtityf pfgbcm rjve eujlyj rhjvt gjkmpjdfntkz jn bvtyb rjnjhjuj pfgecrftncz cthdth.
hbvth
RewriteLog "/usr/local/var/apache/logs/rewrite.log" 
RewriteLogLevel bhtrnbdf
gbcfybt: cnfyfdkbdftn ehjdtym ltnfkbpfwbb ghb ;ehyfkbpfwbb ltqcndbq vt[fybpvf ghtj,hfpjdfybq
bynfrcbc: RewriteLogLevel Level
yfxtybt gj evjkxfyb.: RewriteLogLevel 0
jyntrcn: server configvirtual host
nfnec: fcibhtybt
jlekm: mod_rewrite

bhtrnbdf RewriteLogLevel ecnfyfdkbdftn ehjdtym ltnfkbpfwbb ;ehyfkf vt[fybpvf ghtj,hfpjdfybq. j-evjkxfyb. ehjdtym 0 jpyfxf.obq xnj ;ehyfkbpfwbz yt dtltncz, d nj dhtvz rfr 9 bkb ,jktt jpyfxftn xnj pfgbcsdf.ncz ghfrnbxtcrb dct ltqcndbz.

kz jnrk.xtybz ;ehyfkbpfwbb ltqcndbq vt[fybpvf ghtj,hfpjdfybq ghjcnj ecnfyjdbnt ehjdtym yf 0. nj jnrk.xftn dtltybt ;ehyfkf lkz dct[ ltqcndbq gj ghtj,hfpjdfybzv.

cgjkmpjdfybt ,jkmib[ pyfxtybq ehjdyz jxtym cbkmyj pfvtlkbn dfi cthdth Apache! cgjkmpeqnt ;ehyfk ghtj,hfpjdfybq yf ehjdyt ,jkmitv xtv 2 njkmrj lkz jnkfljxys[ wtktq!
hbvth
RewriteLogLevel 3 
RewriteMap bhtrnbdf
gbcfybt: ghtltkztn aeyrwb. cjplfybz fccjwbfnbdyjuj vfccbdf lkz gjbcrf gj rk.xe
bynfrcbc: RewriteMap MapNameMapType:MapSource
yfxtybt gj evjkxfyb.: ytn
jyntrcn: server configvirtual host
nfnec: fcibhtybt
jlekm: mod_rewrite
jdvtcnbvjcnm: s,jh hfpys[ nbgjd dbm ljcnegty d Apache 2.0.41 b ,jktt gjplyb[ dthcbz[

bhtrnbdf RewriteMap fccjwbfnbdysq vfccbd ghtj,hfpjdfybq, rjnjhsq vj;tn ,snm bcgjkmpjdfy d ghfdbkf[ ghtj,hfpjdfybq b bcgjkmpe.obq cjjndtncnde.obt aeyrwbb lkz dcnfdrb/bpdktxtybz 'ktvtynjd, lkz gjbcrf gj rk.xe cjjndtncnde.ob[ pyfxtybq. cnjxybr 'njuj gjbcrf vj;tn bvtnm hfpkbxysq nbg.

MapName 'nj bvz vfccbdf rjnjhjt ,eltn bcgjkmpjdfnmcz lkz gjbcrf cjjndtncnde.otuj pyfxtybz bp vfccbdf d ghfdbkt ghtj,hfpjdfybz xthtp jlby bp cktle.ob[ rjycnhernjhjd:

${MapName:LookupKey}
${MapName:LookupKey|DefaultValue}

julf dcnhtxftncz gjlj,yfz rjycnherwbz, ghjbc[jlbn j,hfotybt r vfccbde MapName b gjbcr pyfxtybz cjgjcnfdktyyjuj rk.xe LookupKey. ckb yfqltyj bcrjvjt pyfxtybt rk.xf, ghjbc[jlbn bpdktxtybt pyfxtybz SubstValue c gjvjom. cjjndtncnde.otq aeyrwbb. ckb rk.x yt yfqlty njulf ghjbc[jlbn gjlcnfyjdrf DefaultValue bkb gecnjq cnhjrb tckb yt erfpfyf DefaultValue.

juen ,snm bcgjkmpjdfys cktle.obt rjv,byfwbb nbgf aeyrwbb MapType lkz dcnfdrb/bpdktxtybz 'ktvtynjd vfccbdf b MapSource cfvjuj fccjwbfnbdyjuj vfccbdf:

  • hjcnjq ntrcn
    MapType: txt, MapSource: enm r ceotcnde.otve afqke d afqkjdjq cbcntvt Unix

    nj cnfylfhnyfz jgwbz lkz cjplfybz fccjwbfnbdyjuj vfccbdf ult MapSource 'nj ghjcnjq ntrcnjdsq ASCII afqk cjlth;fobq kb,j gecnsq cnhjxrb, cnhjxrb rjvvtynfhbtd (yfxbyf.obtcz c cbvdjkf '#') kb,j gfhs gjlj,yst cktle.obv jlyf d cnhjxrt:

    MatchingKeySubstValue

    hbvth
    ## ## map.txt -- vfccbd ghtj,hfpjdfybq ## Ralf.S.Engelschall rse # Bastard Operator From Hell Mr.Joe.Average joe # Mr. Average 

    RewriteMap real-to-user txt:/path/to/file/map.txt

  • hjbpdjkmysq ghjcnjq ntrcn
    MapType: rnd, MapSource: enm r ceotcnde.otve afqke d afqkjdjq cbcntvt Unix

    njn dfhbfyn bltynbxty dfhbfyne c ghjcnsv ntrcnjv ghbdtlyyjv dsit yj cj cgtwbfkmyjq jcj,tyyjcnm. gjcn-j,hf,jnrb: jckt yf[j;ltybz rfre.-kb,j dtkbxbye ghjbpdjlbncz t fyfkbp yf ghtlvtn yf[j;ltybz cbvdjkjd | rjnjhst bvt.n pyfxtybt kjubxtcrjuj bkb. heubvb ckjdfvb jyb jpyfxf.n yf,jh fkmnthyfnbdys[ dfhbfynjd b ds,jh djpdhfoftvjq dtkbxbys bp yb[ ghjbpdjlbncz ghjbpdjkmyj. jnz 'nj rf;tncz ,tpevbtv b f,cjk.nyj ,tcgjktpysv, 'nj d ltqcndbntkmyjcnb bcgjkmpetncz lkz ,fkfycbhjdrb yfuheprb d cbnefwbz[ c j,hfnysv ghjrcb ult ghjbc[jlbn gjbcr bvty cthdthjd. fghbvth:

    ## ## map.txt -- vfccbd ghtj,hfpjdfybq ## static www1|www2|www3|www4 dynamic www5|www6 

    RewriteMap servers rnd:/path/to/file/map.txt

  • 'i afqk
    MapType: dbm[=type], MapSource: enm r ceotcnde.otve afqke d afqkjdjq cbcntvt Unix

    ltcm, bcnjxybr 'nj ldjbxysq afqk DBM ajhvfnf cjlth;fobq nj ;t cfvjt cjlth;bvjt xnj b ghjcnjq ntrcnjdsq afqk, jlyfrj d cgtwbfkmyjv dblt, jgnbvbpbhjdfyyjv lkz ltqcndbntkmyj ,scnhjuj gjbcrf. njn nbg vj;tn ,snm sdbm, gdbm, ndbm, bkb db d pfdbcbvjcnb jn yfcnhjtr ghb rjvgbkzwbb. ckb nbg jgeoty, ds,bhftncz nbg ecnfyjdktyysq gj-evjkxfyb. ghb rjvgbkzwbb. s vj;tnt cjplfdfnm nfrjq afqk k.,jq enbkbnjq DBM bkb cktle.obv Perl crhbgnjv. ,tlbntcm xnj jy yfcnhjty lkz cjplfybz nht,etvjuj nbgf DBM afqkf. njn ghbvth cjplftn afqk NDBM.

    #!/path/to/bin/perl ## ## txt2dbm -- convert txt map to dbm format ##
    use NDBM_File; use Fcntl; ($txtmap, $dbmmap) = @ARGV; open(TXT, "<$txtmap") or die "Couldn't open $txtmap!n"; tie (%DB, 'NDBM_File',
    $dbmmap,O_RDWR|O_TRUNC|O_CREAT, 0644) or die "Couldn't create $dbmmap!n"; while (<TXT>) { next if (/^s*#/ or /^s*$/); $DB{$1} = $2 if (/^s*(S+)s+(S+)/); } untie %DB; close(TXT);

    $ txt2dbm map.txt map.db

  • yenhtyyzz aeyrwbz
    MapType: int, MapSource: dyenhtyyzz aeyrwbz Apache

    ltcm, bcnjxybr 'nj rfrfz-kb,j dyenhtyyzz aeyrwbz Apache. yfcnjzott dhtvz ds yt vj;tnt cjplfdfnm cdjb cj,cndtyyst aeyrwbb, jlyfrj e;t ceotcnde.n cktle.obt aeyrwbb:

    • toupper:
      htj,hfpetn rk.x gjbcrf d dth[ybq htubcnh.
    • tolower:
      htj,hfpetn rk.x gjbcrf d yb;ybq htubcnh.
    • escape:
      hfyckbhetn cgtwbfkmyst cbvdjks d rk.xt gjbcrf d b[ xbckjdst rjls.
    • unescape:
      hfyckbhetn xbckjdst rjls d rk.xt gjbcrf j,hfnyj d cgtwbfkmyst cbvdjks.
  • ytiyzz ghjuhfvvf ghtj,hfpjdfybz
    MapType: prg, MapSource: enm r ceotcnde.otve afqke d afqkjdjq cbcntvt Unix

    ltcm, bcnjxybr 'nj ghjuhfvvf, f yt afqk c fccjwbfnbdysv vfccbdjv. kz t cjplfybz ds vj;tnt bcgjkmpjdfnm k.,jq ds,hfyysq zpsr, jlyfrj htpekmnfn ljk;ty ,snm bcgjkyztvsv afqkjv (n.t., kb,j j,]trnysv rjljv kb,j crhbgnjv c vfubxtcrjq gthdjq cnhjxrjq '#!/path/to/interpreter').

    nf ghjuhfvvf pfgecrftncz jlby hfp ghb pfgecrt cthdthf Apache b pfntv dpfbvjltqcndetn c vt[fybpvjv ghtj,hfpjdfybq xthtp afqkjdst j,hf,jnxbrb stdin(gjnjr ddjlf) b stdout(gjnjr dsdjlf). kz rf;ljuj gjbcrf d vfccbdt, cjjndtncnde.obq rk.x lkz gjbcrf, ,eltn gjkexfnmcz d dblt cnhjrb, gjlfdftvjq yf stdin b jrfyxbdf.otqcz cbvdjkjv gthtdjlf cnhjrb. fntv 'nf ghjuhfvvf ljk;yf dthyenm pyfxtybt yfqltyyjq dtkbxbys d stdout d dblt cnhjrb jrfyxbdf.otqcz cbvdjkjv gthtdjlf cnhjrb kb,j cnhjrjq bp xtnsh[ cbvdjkjd NULL tckb gjbcr ytelfxty (n.t., lkz cjjndtncnde.otuj pyfxtybz rk.xf yt yfqltyj ybrfrjuj pyfxtybz). hbdbfkmyfz ghjuhfvvf htfkbpe.ofz vfccbd 1:1 (n.t., rk.x == pyfxtybt) vj;tn dsukzltnm nfr:

    #!/usr/bin/perl $| = 1; while (<STDIN>) { # ...put here any transformations or lookups... print $_; } 

    lyfrj ,elmnt jxtym jcnjhj;ys:

    1. "Keep it simple, stupid" (KISS) ltkfq 'nj ghjot, lehfxjr, gjnjve xnj tckb 'nf ghjuhfvvf pfdbcytn 'nj gjdtcbn cthdth Apache rjulf dcnhtnbncz ghfdbkj bcgjkmpe.ott 'njn vfccbd (cjplfdftvsq dytiytq ghjuhfvvjq).
    2. kz bp,t;fybz hfcghjcnhfytyyjq jib,rb: ybrjulf yt ltkfqnt ,eathbpjdfyysq ddjl/dsdjl lkz stdout! nj dspjdtn ,tcrjytxyjt pfwbrkbdfybt! nc.lf $|=1 d dsitghbdtltyyjv ghbvtht
    3. cgjkmpeqnt lbhtrnbde RewriteLock lkz jghtltktybz afqkf ,kjrbhjdjr rjnjhsq mod_rewrite vj;tn bcgjkmpjdfnm lkz cby[hjybpfwbb cdzpb c 'njq ghjuhfvvjq. j-evjkxfyb. nfrfz cby[hjybpfwbz yt ghjbpdjlbncz.

bhtrnbdf RewriteMap vj;tn dcnhtxfnmcz ,jktt jlyjuj hfpf. kz rf;ljuj vfccbdf bcgjkmpeqnt jlye RewriteMap lbhtrnbde lkz j,]zdktybz afqkf c vfccbdjv ghtj,hfpjdfybq. nj dhtvz rfr ds yt vj;tnt jghtltkznm vfccbd d rjyntrcnt rfnfkjuf, tuj bcgjkmpjdfybt d 'njv rjyntrcnt rjytxyj ;t djpvj;yj.

fvtxfybtkz ghjcnjuj ntrcnjdjuj b DBM afqkjd rk.xb gjbcrf r'ibhe.ncz zlhjv lj nt[ gjh gjrf yt bpvtybncz nbg mtime afqkf c vfccbdjv bkb gjrf yt ghjbpjqltn htcnfhn cthdthf. frbv j,hfpjv, ds vj;tnt bcgjkmpjdfnm fccjwbfnbdyst vfccbds d ghfdbkf[ rjnjhst bcgjkmpe.ncz lkz rf;ljuj pfghjcf. nj yt ghj,ktvf, gjnjve xnj dytiybq gjbcr ghjbc[jlbn njkmrj jlby hfp!
RewriteOptions bhtrnbdf
gbcfybt: cnfyfdkbdftn rjt-rfrbt cgtwbfkmyst jgwbb lkz vt[fybpvf ghtj,hfpjdfybq
bynfrcbc: RewriteOptions Options
yfxtybt gj evjkxfyb.: None
jyntrcn: server configvirtual hostdirectory.htaccess
fphtitybt: FileInfo
nfnec: fcibhtybt
jlekm: mod_rewrite

bhtrnbdf RewriteOptions ecnfyfdkbdftn ytrjnjhst cgtwbfkmyst jgwbb lkz ntreotq rjyabuehfwbb d rjyntrcnt cthdthf bkb rfnfkjuf. nhjrb Option vjuen bvtnm cktle.obq dbl:

  • 'inherit'
    nj ghbdjlbn d ltqcndbt yfcktljdfybt ntreotq rjyabuehfwbtq rjyabuehfwbb hjlbntkz. rjyntrcnt dbhnefkmyjuj cthdthf 'nj jpyfxftn xnj fccjwbfnbdyst vfccbds, eckjdbz b ghfdbkf jcyjdyjuj cthdthf yfcktle.ncz. rjyntrcnt rfnfkjuf 'nj jpyfxftn xnj eckjdbz b ghfdbkf d rjyabuehfwbjyys[ afqkf[ .htaccess hjlbntkmcrb[ rfnfkjujd yfcktle.ncz.
RewriteRule bhtrnbdf
gbcfybt: ghtltkztn ghfdbkf lkz vt[fybpvf ghtj,hfpjdfybq
bynfrcbc: RewriteRule f,kjyjlcnfyjdrf
yfxtybt gj evjkxfyb.: None
jyntrcn: server configvirtual hostdirectory.htaccess
fphtitybt: FileInfo
nfnec: fcibhtybt
jlekm: mod_rewrite
jdvtcnbvjcnm: kfu cookie ljcnegty d Apache 2.0.40 b ,jktt gjplyb[.

bhtrnbdf RewriteRule b tcnm yfcnjzofz hf,jxfz kjiflrf ghtj,hfpjdfybq. nf lbhtrnbdf vj;tn dcnhtxfnmcz ,jktt jlyjuj hfpf. f;lfz lbhtrnbdf, d 'njv ckexft, jghtltkztn jlyj ghfdbkj ghtj,hfpjdfybz. jhzljr jghtltktybq 'nb[ ghfdbk df;ty, gjnjve xnj 'njn gjhzljr bcgjkmpetncz ghb j,hf,jnrt ghfdbk dj dhtvz hf,jns.

f,kjy 'nj perl cjdvtcnbvjt htuekzhyjt dshf;tybt rjnjhjt ghbvtyztncz r ntreotve URL. ltcm gjl ntreobv gjlhfpevtdftncz pyfxtybt URL rjulf ghbvtyztncz 'nj ghfdbkj. njn URL yt j,zpfntkmyj cjdgflftn c gthdjyfxfkmyj pfghjityysv URL, gjnjve xnj k.,jt rjkbxtcndj ghfdbk djpvj;yj e;t ,skb ghbvtytys r ytve b cjjndtncndtyyj ghtj,hfpjdfkb tuj.

trjnjhst erfpfybz gj cbynfrcbce htuekzhys[ dshf;tybq:

trcn: . .,jq jlbyjxysq cbvdjk [chars] kfcc cbvdkjkd: lby bp cbvdjkjd [^chars] kfcc cbvdkjkd: b jlby bp cbvdjkjd text1|text2 
kmnthyfnbdf: text1 bkb text2 dfynjhs (cbvdjks lkz j,jpyfxtybz rjkbxtcndtyys[ jnyjitybq): ? 0 bkb 1 bp ghtlitcnde.otuj ntrcnf * 0 bkb N bp
ghtlitcnde.otuj ntrcnf (N > 0) + 1 bkb N bp ghtlitcnde.otuj ntrcnf (N > 1)
heggbhjdrf: (text) heggbhjdrf ntrcnf (kb,j ecnfyjdrf uhfybw fkmnthyfnbds bkb lkz cjplfybz j,hfnys[ cdzptq ult N uheggf, rjnjhfz vj;tn ,snm bcgjkmpjdfyf d
RHS lbhtrnbds RewriteRule c $N) fhrths: ^ fhrth yfxfkf cnhjrb $ fhrth rjywf cnhjrb
rhfybhjdfybt: char 'rhfybhjdfybt rjyrhtnyjuj cbvdjkf (r ghbvthe lkz erfpfybz cbvdjkjd ".[]()" b n.l.) 

jktt gjlhj,ye. byajhvfwb. j htuekzhys[ dshf;tybz[, cvjnhbnt d ljrevtynfwbb gj htuekzhysv dshf;tybzv Perl ("perldoc perlre"). ckb ds pfbynthtcjdfys d to ,jktt ltnfkmyjq byajhvfwbb j htuekzhys[ dshf;tybz[ b b[ lbfktrnf[ (POSIX b n.l.), cvjnhbnt cktle.oe., cgtwbfkmyj yfgbcfyye. gj 'njq ntvt rybue:

Mastering Regular Expressions
Jeffrey E.F. Friedl
Nutshell Handbook Series
O'Reilly & Associates, Inc. 1997
ISBN 1-56592-257-3

hjvt njuj, d mod_rewrite cbvdjk jnhbwfybz (NOT) ('!') ljgecrftvsq ghtabrc d if,kjyt. nj lfn dfv djpvj;yjcnm bydthnbhjdfnm ltqcndbt if,kjyf; ye r ghbvthe crf;tv: "tckb ntreobq URLyt cjdgflftn c 'nbv if,kjyjv". nj vj;tn ,snm bcgjkmpjdfyj d jcj,s[ ckexfz[, rjulf ghjot yfqnb if,kjy lkz ytcjjndtncndbz, bkb d rfxtcndt gjcktlytuj ghfdbkf, hf,jnf.otuj gj evjkxfyb..

hbvtxfybthb bcgjkmpjdfybb cbvdjkf NOT (yt) lkz bydthnbhjdfybz ltqcndbz if,kjyf ds yt vj;tnt bvtnm cuheggbhjdfyyst xfcnb uheggjds[ cbvdjkjd d if,kjyt. nj ytdjpvj;yj gjnjve xnj rjulf ytn cjjndtncndbz if,kjye, lkz uhegg ytn ybrfrjuj cjlth;bvjuj. htpekmnfnt, tckb bcgjkmpe.ncz if,kjys c jnhbwfybtv, ds yt vj;tnt bcgjkmpjdfnm $N d cnhjrf[ gjlcnfyjdjr!

jlcnfyjdrf d ghfdbkt ghtj,hfpjdfybz 'nj cnhjrf ,eltn gjlcnfdkznmcz (bkb ,eltn pfvtyznm) dvtcnj jhbubyfkmyjuj URL, lkz rjnjhjuj tcnmcjdgfltybt f,kjye. hjvt ghjcnjuj ntrcnf ds vj;tnt bcgjkmpjdfnm

  1. j,hfnyst cdzpb $N yf if,kjys d RewriteRule
  2. j,hfnyst cdzpb %N yf gjcktlybq cjjndtncnde.obq if,kjy d RewriteCond
  3. gthtvtyyst cthdthf d rfxtcndt ghjdthztvs[ cnhjr d eckjdbz[ ghfdbk (%{VARNAME})
  4. dspjds pfghjcjd r vfccbde (${mapname:key|default})

,hfnyst cdzpb 'nj $N (N=0..9) bltynbabrfnjhs rjnjhst pfvtyz.ncz cjlth;bvsv N-q uheggs gjl[jlzotuj f,kjyf. thtvtyyst cthdthf nj nj;t cfvjt xnj b hfdybdftvfznhjrf lbhtrnbds RewriteCond. fghjcs r vfccbde ghbikb bp lbhtrnbds RewriteMap nfv jyb b j,]zcytys. nb nhb nbgf gthtvtyys[ hfccvfnhbdf.ncz d gjhzlrt, d rjnjhjv jyb blen d dsitghbdtltyyjv cgbcrt.

fr e;t ,skj egjvzyenj dsit, dct ghfdbkf ghtj,hfpjdfybq ghbvtyz.ncz c bcgjkmpjdfybtv jlcnfyjdrb (d gjhzlrt, d rjnjhjv jyb jghtltktys d rjyabuehfwbjyyjv afqkt). URL gjkyjcnm. pfvtyztncz jlcnfyjdrjq b ghjwtcc ghtj,hfpjdfybz bltn lj nt[ gjh, gjrf yt jcnfytncz ,jkmit ybrfrb[ ghfdbk, tckb njkmrj jy yt ghthdfy cgtwbfkmyj, c gjvjom. akfuf L cv. yb;t.

eotcndetn cgtwbfkmyfz cnhjrf gjlcnfyjdrb dblf '-' rjnjhfz jpyfxftn: gjlcnfyjdrb! dexbn ukegj? tn, 'nj gjktpyj lkz ghfdbk ghtj,hfpjdfybz rjnjhst njkmrj ghjdthz.n ytrjnjhst URL jlyfrj yt ghjbpdjlzn gjlcnfyjdjr, n.t., d cdzprt c akfujv C (wtgjxrf) djpvj;yj bvtnm ,jktt xtv jlby if,kjy, ghbvtyztvsq gthtl ghjdtltybtv ytgjchtlcndtyyj cfvjq gjlcnfyjdrb.

o jlyj pfvtxfybt: s lf;t vj;tnt cjplfdfnm URL, cjlth;fobt cnhjre pfghjcf, d cnhjrt gjlcnfyjdrb. hjcnj bcgjkmpeqnt djghjcbntkmysq pyfr dyenhb cnhjrb gjlcnfyjdrb lkz erfpfybz njuj, cktle.ott pf ybv cjlth;bvjt ljk;yj ,snm ghtj,hfpjdfyj d QUERY_STRING (cnhjre pfghjcf). julf ds [jnbnt e,hfnm ceotcnde.oe. cnhjre pfghjcf, pfdthifqnt cnhjre gjlcnfyjdrb ghjcnj djghjcbntkmysv pyfrjv.

hbvtxfybtcnm jlyf jcj,tyyjcnm: julf ds ghtldfhztnt gjkt gjlcnfyjdrb cnhjrjq http://thishost[:thisport], mod_rewrite jnhtpftn t fdnjvfnbxtcrb. nj fdnjvfnbxtcrjt ectxtybt gjlhfpevtdftvjt ghb dytiytv htlbhtrnt URL gjktpyfz b df;yfz jcj,tyyjcnm ghb bcgjkmpjdfybb d cdzprt c pfghjcfvb r vfccbdfv ghtj,hfpjdfybq utythbhe.ob[ bvz [jcnf. pukzybnt yf gthdsq ghbvth, d hfpltkt ghbvthjd yb;t, xnj,s gjyznm 'nj.
jvybnttpeckjdysq dytiybq htlbhtrn yf dfi cj,cndtyysq cthdth yt ,eltn hf,jnfnm c ghtabrcjv http://thishost bp-pf 'njq jcj,tyyjcnb. nj,s bcgjkmpjdfnm nfrjq cfvjhtlbhtrn, s ljk;ys bcgjkmpjdfnm akfu R(cv. yb;t).

gjlcnfyjdrt ds vj;tnt bcgjkmpjdfnm, d njv xbckt, b cgtwbfkmyst akfub gentv lj,fdktybz cktle.otq rjycnherwbb:

[akfub]

d rfxtcndt nhtnmtuj fhuevtynf lbhtrnbds RewriteRule. kfub 'nj hfpltkyysq pfgznsvb, cktle.obq cgbcjr akfujd:

  • 'redirect|R [=code]' (dspsdftn htlbhtrn)
    htabrc d jlcnfyjdrt dblf http://thishost[:thisport]/ (cjplf.obq yjdsq URL bp rfrjuj-kb,j URI) pfgecrftn dytiybq htlbhtrn (gthtyfghfdktybt). ckb ytn yfrfrjuj rjlf d gjlcnfyjdrt jndtn ,eltn c HTTP cnfnecjv 302 ( ). ckb ds [jnbnt bcgjkmpjdfnm lhrubt rjls jndtnjd d lbfgfpjyt 300-400, ghjcnj yfgbibnt b[ d dblt xbckf bkb bcgjkmpeqnt jlyj bp cktle.ob[ cbvdjkbxtcrb[ bvy: temp (gj-evjkxfyb.), permanent, seeother. cgjkmpeqnt 'nj d lbhtrnbdf[, rjnjhst ljk;ys ghtj,hfpjdsdfnm ytrbt dbhnefkmyst URL d htfkmyst b djpdhfofnm b[ rkbtyne, yfghbvth, ghtj,hfpjdsdfnm /~ d /u/ bkb dctulf lj,fdkznm ck'i r /u/user, b n.l.

    hbvtxfybt: hb bcgjkmpjdfybb 'njuj akfuf, e,tlbntcm, xnj gjkt gjlcnfyjdrb, 'nj hf,jnf.obq URL! ckb 'nj yt nfr, ds gthtyfghfdkztnt d ybrelf! gjvybnt, xnj cfv gj ct,t 'njn akfu, njkmrj ljgjkyztn URL cnhjrjq http://thishost[:thisport]/, b ghjwtcc ghtj,hfpjdfybz ghjljk;ftncz. fr;t, j,sxyj ds [jnbnt jcnfyjdbnmcz b cltkfnm 'njn htlbhtrn ytvtlktyyj. kz jcnfyjdrb ghjwtccf ghtj,hfpjdfybz, dfv nfr;t ye;yj yfgbcfnm akfu 'L'.

  • 'forbidden|F' (ltkftn URL pfghtotyysv)
    nj ltkftn ntreobq URL pfghtoyysv, yfghbvth, rkbtyne ytvtlktyyj jnghfdkztncz jndtn c HTTP cnfnecjv 403 (). cgjkmpeqnt 'njn akfu d cjxtnfybb c cjjndtncnde.obvb RewriteConds lkz ,kjrbhjdfybz URL gj ytrjnjhsv rhbnthbzv.
  • 'gone|G' (ltkftn URL vhndsv)
    njn akfu ltkftn ntreobq URL vthndsv, n.t., ytvtlktyyj jnghfdkztncz HTTP jndtn cj cnfnecjv 410 (GONE). cgjkmpeqnt 'njn akfu lkz vfhrbhjdrb vthndsvb yt ceotcnde.obt ,jktt cnhfybws.
  • 'proxy|P' (dspdftn ghjrcb)
    njn akfu gjvtxftn gjlcnfyjdjxye. xfcnm rfr dyenhtyybq pfghjc ghjrcb b ytvtlktyyj (n.t., ghjwtcc ghtj,hfpjdfybz pltcm jcnfyfdkbdftncz) ghjgecrftn tuj xthtp ghjrcb vjlekm. s ljk;ys e,tlbnmcz, xnj cnhjrf gjlcnfyjdrb 'nj htfkmysq URI (yfghbvth, nbgbxyj yfxbyf.obqcz c http://hostname), rjnjhsq vj;tn ,snm j,hf,jnfy ghjrcb vjlektv Apache. ckb 'nj yt nfr, ds gjkexbnt jib,re jn ghjrcb vjlekz. cgjkmpeqnt 'njn akfu lkz njuj, xnj,s lj,bnmcz ,jktt vjoyjq htfkbpfwbb lbhrtnbds ProxyPass, byntuhbhe.otq ytrjnjhjt cjlth;bvjt yf elfktyys[ cthdthf[, d ghjcnhfycndj bvy kjrfkmyjuj cthdthf.

    hbvtxfybt: kz njuj xnj,s 'nj bcgjkmpjdfnm e,tlbntcm xnj e dfc tcnm hf,jnf.obq ghjrcb vjlekm yf dfitv cthdtht Apache. ckb ds yt pyftnt 'njuj ghjdthmnt tcnm kb d dsdjlt httpd -l cnhjxrf mod_proxy.c. ckb lf, 'nb djpvj;yjcnb ljcnegys mod_rewrite. ckb ytn, nj cyfxfkf ds ljk;ys gthtcj,hfnm ghjuhfvve httpd c drk.xtyysv ghjrcb vjlektv.

  • 'last|L' (gjcktlytt ghfdbkj)
    cnfyjdbnm ghjwtcc ghtj,hfpjdfybz yf 'njv vtcnt b yt ghbvtyznm ,jkmit ybrfrb[ ghfdbk ghtj,hfpjdfybq. nj cjjndtncndetn jgthfnjhe last d Perl bkb jgthfnjhe break d zpsrt C. cgjkmpeqnt 'njn akfu lkz njuj, xnj,s yt ghtj,hfpjdsdfnm ntreobq URL lheubvb, cktle.obvb pf 'nbv, ghfdbkfvb ghtj,hfpjdfybq. ghbvthe, bcgjkmpeqnt 'nj lkz ghtj,hfpjdfybz rjhytdjuj URL bp ('/') d htfkmysq, yfghbvth, '/e/www/'.
  • 'next|N' (cktle.ibq hfeyl)
    thtpfgecnbnm ghjwtcc ghtj,hfpjdfybq (yfxfd c gthdjuj ghfdbkf). 'njv ckexft URL cyjdf cjgjcnfdkztncz ytrbv eckjdbzv, yj yt jhbubyfkmysq URL, f URL dsitlibq bp gjcktlytuj ghfdbkf ghtj,hfpjdfybz. nj cjjndtncndetn jgthfnjhe next d Perl bkb jgthfnjhe continue bp zpsrf C. cgjkmpeqnt 'njn akfu lkz gthtpfgecrf ghjwtccf ghtj,hfpjdfybq, n.t., ,tpeckjdyjve gtht[jle yf yfxfkj wbrkf.
    lyfrj ,elmnt jcnjhj;ys, lkz njuj xnj,s yt cltkfnm ,tcrjytxysq wbrk!
  • 'chain|C' (cdzpm cj cktle.obv ghfdbkjv)
    njn akfu cdzpsdftn ntreott ghfdbkj cj cktle.obv (rjnjhjt, d cdj. jxthtlm, vj;tn ,snm cdzpfyj cj cktle.obv pf ybv, b n.l.). nj bvttn cktle.obq 'aatrn: tckb tcnm cjjndtncndbt ghfdbke, ghjwtcc ghjljk;ftncz rfr j,sxyj, n.t., akfu yt ghjbpdjlbn ybrfrjuj 'aatrnf. ckb ghfdbkj yt cjjndtncndetn eckjdb., dct cktle.obt, cdzpfyyst ghfdbkf, ghjgecrf.ncz. fghbvth, bvgjkmpeqnt 'nj lkz elfktybz .www xfcnb d rjyabuehfwbjyyjv ghfdbkt rjyntrcnf rfnfkjuf hf,jnf.otuj rjulf ds hfphtiftnt dytiybq htlbhtrn (ult yt ljk;yj ,snm .www!).
  • 'type|T=MIME-nbg' (ghbyelbntkmyj ecnfyjdbnm MIME nbg)
    hbyelbntkmyj ecnfyjdbnm MIME-nbg wtktdjuj afqkf d MIME-nbg. ghbvthe, 'nj vj;yj bcgjkmpjdfnm lkz bvbnfwbb mod_alias lbhtrnbds ScriptAlias rjnjhfz ghbyelbntkmyj ecnfyfdkbdftn lkz dct[ afqkjd dyenhb jnj,hf;ftvjuj rfnfkjuf MIME nbg hfdysq application/x-httpd-cgi.
  • 'nosubreq|NS' (bcgjkmpetncz njkmrj d ckexft ytdyenhtyytuj gjlpfghjcf)
    njn akfu lftn rjvfyle vt[fybpve ghtj,hfpjdfybq ghjgecnbnm lbhtrnbde tckb ntreobq gjlpfghjc zdkztncz dyenhtyybv gjlpfghjcjv. ghbvthe, dyenhtyybt gjlpfghjcs d Apache ghjbc[jlzn njulf, rjulf mod_include gsnftncz gjkexbnm byajhvfwb. j djpvj;ys[ afqkf[ gj-evjkxfyb. lkz rfnfkjujd (index.xxx). hb gjlpfghjcf[ 'nj yt dctulf gjktpyj b lf;t byjulf dspsdftn ghj,ktve d hf,jnt dctuj yf,jhf lbhtrnbd ghtj,hfpjdfybq. cgjkmpeqnt 'njn akfu lkz bcrk.xtybz ytrjnjhs[ ghfdbk.

    cgjkmpeqnt cktle.ott ghfdbkj gj cdjtve ecvjnhtyb.: dczrbq hfp rjulf ds ghtldfhztnt ytrjnjhst URL ghtabrcjv gthtlfdfz b[ yf j,hf,jnre CGI-crhbgne, dtkbr ifyc xnj ds yfgjhtntcm yf ghj,ktvs (bkb lf;t yf ytye;yst bplth;rb) d ckexft ghbvtytybz gjlpfghjcjd. 'nb[ ckexfz[, bcgjkmpeqnt 'njn akfu.

  • 'nocase|NC' (yt exbnsdfnm htubcnh)
    nj ltkftn f,kjy ytxecndbntkmysv r htubcnhe, n.t., ytn hfpkbxbq vt;le 'A-Z' b 'a-z' rjulf f,kjy ghbvtyztncz r ntreotve URL.
  • 'qsappend|QSA' (lj,fdkznm cnhjre pfghjcf)
    njn akfu erfpsdftn vt[fybpve ghtj,hfpjdfybq yf lj,fdktybt f yt pfvtye, cnhjrb pfghjcf bp URL r ceotcnde.otq, d cnhjrt gjlcnfyjdrb. cgjkmpeqnt 'nj rjulf ds [jnbnt lj,fdkznm ljgjkybntkmyst lfyyst d cnhjre pfghjcf c gjvjom. lbhtrnbd ghtj,hfpjdfybq.
  • 'noescape|NE' (yt 'rhfybhjdfnm URI ghb dsdjlt)
    njn akfu yt lfn mod_rewrite ghbvtyznm j,sxyst ghfdbkf 'rhfybhjdfybz URI r htpekmnfne ghtj,hfpjdfybz. ,sxyj, cgtwbfkmyst cbvdjks (nfrbt rfr '%', '$', ';', b nfr lfktt) ,elen 'rhfybhjdfys b[ itcnyflwfnbhbxysvb gjlcnfyjdrfvb ('%25', '%24', b '%3B', cjjndtncndtyyj); 'njn akfu yt lftn 'nj ltkfnm. nj gjpdjkztn cbvdjkfv ghjwtynf gjzdkzncz yf ds[jlt , rfr d

    RewriteRule /foo/(.*) /bar?arg=P1%3d$1 [R,NE]

    lkz rjnjhjuj '/foo/zed' ghtj,hfpjdsdfkjcm ,s d ,tpjgfcysq pfghjc '/bar?arg=P1=zed'.
  • 'passthrough|PT' (ghjgecrfnm xthtp cktle.obq j,hf,jnxbr)
    njn akfu lfn rjvfyle vt[fybpve ghtj,hfpjdfybq ecnfyfdkbdfnm gjkt uri dyenhtyytq cnhernehs request_rec hfdysv gjk. filename. njn akfu, ghjcnj kbim [bnhsq nh.r, lkz njuj xnj,s bvtnm djpvj;yjcnm j,hf,jnrb dsdjlf lbhtrnbd RewriteRule, lbhtrnbdfvb Alias, ScriptAlias, Redirect, b n.l. bp lheub[ nhfyckznjhjd URI-bvz afqkf. hbdbfkmysq ghbvth lkz gjrfpf 'njq ctvfynbrb: tckb ds [jnbnt ghtj,hfpjdfnm /abc d /def c bcgjkmpjdfybtv vt[fybpvf ghtj,hfpjdfybq mod_rewrite b pfntv /def d /ghi c bcgjkmpjdfybtv mod_alias:

    RewriteRule ^/abc(.*) /def$1 [PT]
    Alias /def /ghi

    ckb ds jgecnbnt akfu PT, mod_rewrite ghtrhfcyj cltkftnc cdj. hf,jne, n.t., jy ghtj,hfpetn uri=/abc/... d filename=/def/... rfr ljk;ty ltkfnm gjkyjcnm. API-cjdvtcnbvsq nhfyckznjh URI-bvz afqkf. fntv yfcnfn jxthtlm mod_alias gsnf.otujcz cltkfnm gtht[jl URI-bvz afqkf rjnjhsq b yt ,eltn hf,jnfnm.

    hbvtxfybt: s ljk;ys bcgjkmpjdfnm 'njn akfu tckb ds [jnbnt cvtibdfnm lbhtrnbds hfpys[ vjlektq cjlth;fob[ nhfyckznjhs URL-bvz afqkf. bgbxysq ghbvth 'nj bcgjkmpjdfybt vjlektq mod_alias b mod_rewrite..

    kz k.,bntktq gjrjdshznmcz d Apacheckb ,s ntreobq Apache API bvtk rfrjq-yb,elm gtht[dfnxbr bvz afqkf-bvz afqkf d ljgjkytybt r gtht[dfnxbre URI-bvz afqkf yfv ,s yt gjyflj,bkcz lfyysq akfu! lyfrj ,tp nfrjuj gtht[dfnxbrf 'njn akfu 'nj tlbycndtyyjt htitybt. The Apache Group j,celbkf 'ne ghj,ktve b lj,fdbn nfrjq gtht[dfnxbr dj 2-q dthcbb Apache.
  • 'skip|S=rjkbxtcndj' (ghjgecnbnm cktle.ott ghfdbkj(f))
    njn akfu erfpsdftn vt[fybpve ghtj,hfpjdfybq ghjgecrfnm cktle.ott rjkbxtcndj ghfdbk d gjcktljdfntkmyjcnb yfxbyf.otqcz c ntreotuj ghfdbkf. cgjkmpeqnt 'nj lkz cjplfybz gctdlj if-then-else rjycnherwbq: jcktlytt ghfdbkj ,kjrf then ,eltn skip=N ult N rjkbxtcndj ghfdbk ,kjrf else. (nj yt nj ;t cfvjt xnj b akfu 'chain|C'!)
  • 'env|E=VAR:VAL' (ecnfyjdbnm gthtvtyye. jreh;tybz)
    hbcdfbdftn gthtvtyyjq jrhe;tybz VAR pyfxtybt VAL, ult VAL vj;tn cjlth;fnm j,hfnyst cdzpb $N b %N ccskf.obtcz yf xfcnb htuekzhys[ dshf;tybq, rjnjhst ,elen hfcrhsns cjjndtncnde.obv j,hfpjv. s vj;tnt bcgjkmpjdfnm 'njn akfu ,jktt jlyjuj hfpf xnj,s ghbcdjbnm pyfxtybt ,jktt xtv jlyjq gthtvtyyjq. jp;t, 'nb gthtvtyyst vjuen ,snm bcgjkmpjdfys dj vyjub[ cbnefwbz[, j,sxyj d XSSI (xthtp <!--#echo var="VAR"-->) bkb d CGI crhbgnf[ (yfghbvth$ENV{'VAR'}). hjvt njuj, ds vj;tnt 'nj bcgjkmpjdfnm d cktle.otv if,kjyt RewriteCond xthtp %{ENV:VAR}. cgjkmpeqnt 'nj lkz elfktybz, yj pfgjvbyfybz ytrjnjhjq byajhvfwbb bp URL.
  • 'cookie|CO=NAME:VAL:domain[:lifetime[:path]]' (pfgbcfnm cocookie)
    fgbcsdftn cookie rkbtyne. vz cookie erfpsdftncz d NAME f tuj pyfxtybt d VAL. jkt domain 'nj ljvty cookie, nfrjq rfr yfghbvth '.apache.org', jgwbjyfkmyjt lifetime 'nj dhtvz ;bpyb cookie d vbyenf[, b jgwbjyfkmysq path 'nj genm cookie
hbvtxfybtbrjulf yt pf,sdfnt xnj f,kjy ghbvtyztncz rj dctve URL d rjyabuehfwbjyys[ afqkf cthdthf. lyfrj d rjyabuehfwbjyys[ afqkf[ rfnfkjujd, ghtabrc rfnfkjuf (rjnjhsq dctulf jlbyfrjd lkz rjyrhtnyjuj rfnfkjuf !), fdnjvfnbxtcrb elfkztncz ghb cjjndtncndbb if,kjye b fdnjvfnbxtcrb lj,fdkztncz gjckt pfdthitybz gjlcnfyjdrb. nf jcj,tyyjcnm, jcyjdf lkz vyjub[ dbljd ghtj,hfpjdfybq, gjnjve xnj ,tp elfktybz ghtabrcf lkz hjlbntkmcrjuj rfnfkjuf nj;t ljk;yj ,snm cjjndtncndbt, xnj yt dctulf djpvj;yj.

cnm jlyj bcrk.xtybt: ckb cnhjrf gjlcnfyjdrb yfxbyftncz c http:// d 'njv ckexft ghtabrc rfnfkjuf yt lj,fdkztncz b ghjbc[jlbn kb,j dytiybq htlbhtrn kb,j ghjgecrfybt xthtp ghjrcb (tckb bcgjkmpetncz akfu P!)!

hbvtxfybtkz njuj xnj,s drk.xbnm vt[fybpv ghtj,hfpjdfybq d rjyabuehfwbjyys[ afqkf[ rfnfkjujd dfv ye;yj yfgbcfnm RewriteEngine On d 'nb[ cfvs[ afqkf[ b, rhjvt njuj, ljk;yf ,snm hfphtityf rjyabuehfwbjyyfz lbhtrnbdf Options FollowSymLinks. ckb dfi flvbybcnhfnjh pfghtnbk gthtuhepre rjyabuehfwbjyyjq lbhtrnbds FollowSymLinks d gjkmpjdfntkmcrb[ rfnfkjuf[, d 'njv ckexft ds yt cvj;tnt bcgjkmpjdfnm vt[fybpv ghtj,hfpjdfybq. nj juhfybxtybt ye;yj gj cjj,hf;tybzv ,tpjgfcyjcnb.

jn dct djpvj;yst rjv,byfwbb gjlcnfyjdjr c hfcibahjdrjq b[ pyfxtybq:

rjyabuehfwbjyys[ afqkf[ rjyntrcnf cthdthf (httpd.conf)
lkz pfghjcf dblf GET /somepath/pathinfo:

hfdbkj jlcnfyjdrf ---------------------------------------------- ---------------------------------- ^/somepath(.*) otherpath$1 
yt gjllth;bdftncz, n.r. ytdthyj! ^/somepath(.*) otherpath$1 [R] yt gjllth;bdftncz,
n.r. ytdthyj! ^/somepath(.*) otherpath$1 [P] yt gjllth;bdftncz, n.r. ytdthyj!
 ---------------------------------------------- ---------------------------------- ^/somepath(.*) /otherpath$1 /otherpath/pathinfo ^/somepath(.*) /otherpath$1 [R]
http://thishost/otherpath/pathinfo xthtp dytiybq htlbhtrn ^/somepath(.*) /otherpath$1 [P] yt gjllth;bdftncz, - ukegj! ----------------------------------------------
---------------------------------- ^/somepath(.*)
http://thishost/otherpath$1 /otherpath/pathinfo ^/somepath(.*) http://thishost/otherpath$1 [R]
 http://thishost/otherpath/pathinfo xthtp dytiybq htlbhtrn ^/somepath(.*) http://thishost/otherpath$1 [P] yt gjllth;bdftncz, - ukegj!
---------------------------------------------- ---------------------------------- ^/somepath(.*) http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo xthtp
dytiybq htlbhtrn ^/somepath(.*)
http://otherhost/otherpath$1 [R] http://otherhost/otherpath/pathinfo xthtp dytiybq htlbhtrn (akfu [R] bp,snjxty) ^/somepath(.*)
http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo xthtp dyenhtyybq ghjrcb 

yenhb rjyabuehfwbjyyjuj afqkf rfnfkjuf, lkz /somepath
(n.t., afqk .htaccess d rfnfkjut /physical/path/to/somepath cjlth;bn RewriteBase /somepath)
lkz pfghjcf GET /somepath/localpath/pathinfo:

hfdbkj jlcnfyjdrf ---------------------------------------------- 
---------------------------------- ^localpath(.*) otherpath$1 /somepath/otherpath/pathinfo ^localpath(.*) otherpath$1 [R]
http://thishost/somepath/otherpath/pathinfo xthtp dytiybq htlbhtrn ^localpath(.*) otherpath$1 [P] yt gjllth;bdftncz, - ukegj!
 ----------------------------------------------
---------------------------------- ^localpath(.*) /otherpath$1 /otherpath/pathinfo ^localpath(.*) /otherpath$1 [R] http://thishost/otherpath/pathinfo
xthtp dytiybq htlbhtrn ^localpath(.*) /otherpath$1 [P] yt gjllth;bdftncz, - ukegj!
---------------------------------------------- 
---------------------------------- ^localpath(.*) http://thishost/otherpath$1 /otherpath/pathinfo ^localpath(.*) http://thishost/otherpath$1 [R]
http://thishost/otherpath/pathinfo xthtp dytiybq htlbhtrn ^localpath(.*) http://thishost/otherpath$1 [P] yt gjllth;bdftncz, - ukegj!
 ---------------------------------------------- ---------------------------------- ^localpath(.*)
 http://otherhost/otherpath$1 http://otherhost/otherpath/pathinfo xthtp dytiybq htlbhtrn ^localpath(.*) http://otherhost/otherpath$1 
[R] http://otherhost/otherpath/pathinfo xthtp dytiybq htlbhtrn (akfu [R] bp,snjxty) ^localpath(.*) http://otherhost/otherpath$1 [P] http://otherhost/otherpath/pathinfo xthtp dyenhtyybq ghjrcb 

hbvth:

s [jnbv ghtj,hfpjdfnm URL dblf

/ Language /~ Realname /.../ File

d

/u/ Username /.../ File . Language

s ,thtv afqk, cjlth;fobq fccjwbfnbdysq vfccbd lkz ghtj,hfpjdfybq, ghbdtlyysq dsit b cj[hfyzt

3
  ,
:
. +7(812) 984 5721

e-mail
icq 415547094  romver  mail.ru  romverinbox.ru
1997 - 2020 romver.ru

Display Pagerank