Kiev1.org Карта сайта Файлы Фотографии Киева
  
Реклама:






???????
 
 Sysadmin
 ??????????????
 ????? ? ?????
 ??????????
 ???????????? ???????
 ?????????????
 ? ???????
 ? ???????????
 ???????? ? ??????
 ???????????
 ??????????? ???????
 ???????? ????? ?????? ?????? ???????? ??????????
 ??????
 ??????
 ?????? ?????? 1924-1994
 ??????? ?? ??????
 ???? ? ???????
 ????? ??????????
 ?????????


Внимание! Читая пророчества на этом сайте помните что достоверность трудно проверить и все может во времени изменяться - самое главное думать своей головой и не верить легкомысленно всему что говорят, особенно советское телевидение
"О дне же том, или часе, никто не знает, ни Ангелы небесные, ни Сын, но только Отец (Мк. 13, 32)"

??????????? ?? URL ???????????????



????? ??????????? ??????????? ????????????? mod_rewrite ???-??????? Apache ??? ??????? ???????? ??????? ? URL ? ???????? ???-??????? ?????? ???????????? ?? ????????. ????? ?????? ????????? ???????? ??????? ?????? ?? ??????? ?? ????????? ??????? ?????? ??? URL ??????????????.
http://www.opennet.ru

???????? ???????
Ralf S. Engelschall <rse@apache.org>
??????? 1997

???????
????????? ?????? <http://www.egoroff.spb.ru/>
??????? 2002

???? ???????? ????????? ???????????? ? mod_rewrite . ????? ??????????? ??????????? ????????????? mod_rewrite ???-??????? Apache ??? ??????? ???????? ??????? ? URL ? ???????? ???-??????? ?????? ???????????? ?? ????????. ????? ?????? ????????? ???????? ??????? ?????? ?? ??????? ?? ????????? ??????? ?????? ??? URL ??????????????.

???????? ? mod_rewrite

?????? mod_rewrite ??? Apache ??? ??????????? ??????, ?.?. ??? ????????????? ???????????????? ?????? ??????????????? ?????? ???????? ??? URL ??????????????. ? ??? ?? ?????? ?????? ????? ??? ???? URL ?????????????? ? ??????? ?? ?????-???? ???????. ????, ??????? ?? ?????? ????????? — ??????? ??? ?????????, ????????? ??????? ?????????? mod_rewrite , — ??? ??, ??? ??? ??????? ?????? ? ???????????? ???????. ? ???? ???????? Apache ?????? ??????? ????? ??????? ??? ?? ????? ?????? mod_rewrite .

??????? ???????: ? mod_rewrite ?? ???? ???? ???? ??????????? ???? ??? ?????? ??????????, ? ??????? ?? ?????? ??? ????? ????????????, ???, ??-?? ??? ????, ???????? ??? ?? ??? ?????????? ?????. ???? ????? ????????? — ???? ??? ????????? ???????, ?????????? ????????, ? ????? ?????? ??? ???????? ??????? ?????????????, ????? ?????? ??????? ???????.

???????????? ???????

????? ???? ????? ???????????? ??????? ?????-?? ??????????? ???? ???? ???? ??????? ??????. ???????????? ??? ???????? ?? ???? ???????? ?????? ????? URL ??????????????.

????????: ? ????? ??????, ? ??????????? ?? ???????????? ?????? ???????, ???????? ??????????? ?????? ???????? ??? ???????, ???????? ???????? ???? [PT] ????? ????????????? ???????????? mod_alias ? mod_userdir , ? ?.?. ??? ?????????? ????? ?????? ??? ???? ????? ??? ???????? ? ????????? .htaccess ? ?? ? ????????? ??????? (httpd.conf). ?????? ????????? ?????? ??? ?? ??????? ?????? ?????????? ????? ??????, ?????? ??? ??? ????????????. ?? ???????? ???????.

?????? ? URL

???????? URL

????????:

?? ????????? ???-???????? ?????????? ????? ?????? URL ??? ??????-???? ???????. ?????? ?????????? ???????? URL (??????? ? ???????????????? ??????? ???????????? ? ??????????????) ? ??, ??????? ?????? ???????? ????????, ???????????, ? ?.?. ?????????? ?? ????, ????? URL ???????????? ???????? ? ????? ???????, ? ????? ??????, ?? ?????? ??????? ?????? ???????? URL.

???????:

??? ???? ??????????? URL, ?? ?????? ??????? HTTP ????????, ????????? ?? ? ? ???????? ?????? ???????? ? ?? ???? ??????????? ????????. ? ??????????? ???? ?????? ?????? /~user ?????????? ???????? /u/user ? ???????????? ????????????? ??????????? ???? ??? /u/user.

RewriteRule   ^/~([^/]+)/?(.*)    /u/$1/$2  [R]
RewriteRule   ^/([uge])/([^/]+)$  /$1/$2/   [R]

???????? ????? ??????

????????:
...
???????:
RewriteCond %{HTTP_HOST}   !^fully.qualified.domain.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*)         http://fully.qualified.domain.name:%{SERVER_PORT}/$1 [L,R]
RewriteCond %{HTTP_HOST}   !^fully.qualified.domain.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://fully.qualified.domain.name/$1 [L,R]

???????????? DocumentRoot

????????:

?????? DocumentRoot ?????????? ? ???????? ????????? ? URL «/». ?????? ????? DocumentRoot ???? ?? ???????? ?????? ??? URL «/» ? ? ????? DocumentRoot ????? ????????????? ????????? ??????. ???????? ??? ????? Intranet ?????? /e/www/ (??????? ???????? WWW), /e/sww/ (??????? ???????? ??? Intranet) ? ?.?. ?????? ??-?? ???? ??? DocumentRoot ???????? «/» ??? /e/www/ ?? ?????? ?????????? ?????? ???? ??????????? ???????? ? ?????? ???????? ??? ???? ??????????? ???????? ???? ???????.

???????:

?? ?????? ??????? ?????????????? URL / ? /e/www/. ? ??????? ??????? ??? ??????? ???????????, — ?????? ? ????????????????, ??? ?????????? ?????? ? mod_rewrite . ???????? ?????? ????????? URL ??????????? (??? ???????? mod_alias ? ??? ?????????) ???????????? ?????? ?????????? ?? ????????. ? ???? ??????, ?? ?? ?????? ?????? ????? ??????????????, ?????? ??? DocumentRoot ???????? ????????? ??? ???? URL. ? ? mod_rewrite ??? ????????????? ??????????:

RewriteEngine on
RewriteRule   ^/$  /e/www/  [R]

???????? ?????????????? ???????????? ?????

????????:

?????? ????????? ????? ????? ????? ? ???????? ????????????? ??????????? ?????? ??? ????????????? URL ??????????? ?? ????????. ???? ??? ???????????, ?????? ?????? ??????, ?????? ??? ???? ?? ?????? /~quux/foo ?????? /~quux/foo/ ?????? ???? ???? foo. ? ????????? ???? ???? ???????? ?????????, ?????????? ??????. ? ????????????????, ? ??????????? ??????? ??? ???????????? ????, ??????, ? ????????? ???????, ????? ????? ??????????? ???? ????????. ????????, ????? ????, ??? ?? ??????? ????? ??????? ?????????? URL ?? CGI ??????? ? ?.?.

???????:

??????? ???? ?????? ???????? — ??? ????????? ??????? ????????? ??????????? ???? ?????????????. ????? ??????? ??? ?????????, ?? ?????? ???????????? ??????? ????????, ??? ???? ????? ??????? ????????? ?????????? ???????? ? ??. ? ?????? ???? ?? ?? ??????? ?????? ?????????? ????????, ??? ?? ???????? ?????? ??? ????? ???????? ???????? (???????? ??-?????????), ?????? ???? ?? ???????? ??? ??????? ????? ???????? ?? ???? ???????? ? ?????????????? URL, ?????? ??? ??????? ?????? ?? ?????? ?? ??????? in-lined ???????. ????????, ?????? ??? image.gif ?? ???????? /~quux/foo/index.html ??? ???????? ????????? ???????? ?? ??? /~quux/image.gif!

???????, ??? ???? ????? ??????? ??? ????, ?? ?????:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo$  foo/  [R]

?????????? ? ??????? ????? ???? ??????? ???????? ? ????? .htaccess ??????????? ? ????? ???-???????????? ?????? ?????. ??????, ??????? ????????, ??? ??? ??????? ????????? ????????? ???????.

RewriteEngine  on
RewriteBase    /~quux/
RewriteCond    %{REQUEST_FILENAME}  -d
RewriteRule    ^(.+[^/])$           $1/  [R]

???-??????? ????? ???? URL

????????:

?? ????? ??????? ?????????? ? ?????????? URL ??? ???? WWW ???????? ? Intranet ???-????????, ?.?. ??? URL (?????????? ????????? ???????? ? ????? ??????? ????????? ?? ???????!) ??????????, ? ????????????????, ???????????? ?? ???????! ?? ??? ?? ?????, — ??? ??? ???? ???????????? ???? WWW ?????????? ??????????? ?? ??????? ?????: ??????? URL ?? ?????? ???????? ?????-???? ???????? ??????. ??????? ??? ?????? ????????????? ?????????????? ??? ?? ???????? ??????.

???????:

??????, ?????????? ? ?????????? ???????? ??????? ?? (??????????????) ??????? ???????? ??????? ???????? ?????????? ? ???, ??? ????????? ???? ????????????, ?????? ? ???????. ????? ????? ?????:

user1  server_of_user1
user2  server_of_user2
:      :

?? ???????? ??? ?????? ? ????? map.xxx-to-host. ??????, ?? ?????? ????????????? ??? ???? ??????? ?????????????? URL ????

/u/user/anypath
/g/group/anypath
/e/entity/anypath

??

http://physical-host/u/user/anypath
 http://physical-host/g/group/anypath
 http://physical-host/e/entity/anypath

????? URL ?? ????????? ?? ?????-???? ????????? ???????. ????????? ????? ?????? ?????? ??? ??? ??? ??? ?????? ?????? c ?????????????? ????????? ??? ?????????????? (?????? ??? server0 — ??? ??????, ??????? ????? ??????????? ??-?????????, ???? ? ??????? ??? ?????? ??? ??????-???? ????????????):

RewriteEngine on

RewriteMap      user-to-host   txt:/path/to/map.user-to-host
RewriteMap     group-to-host   txt:/path/to/map.group-to-host
RewriteMap    entity-to-host   txt:/path/to/map.entity-to-host

RewriteRule   ^/u/([^/]+)/?(.*)   http://${user-to-host:$1|server0}/u/$1/$2
RewriteRule   ^/g/([^/]+)/?(.*)  http://${group-to-host:$1|server0}/g/$1/$2
RewriteRule   ^/e/([^/]+)/?(.*) http://${entity-to-host:$1|server0}/e/$1/$2

RewriteRule   ^/([uge])/([^/]+)/?$          /$1/$2/.www/
RewriteRule   ^/([uge])/([^/]+)/([^.]+.+)   /$1/$2/.www/$3

??????????? ???????? ????????? ?? ?????? ???-??????

????????:

????? ??????????? ??????? ??????? ??? ????????? ????????: ??? ?????? ?????? ????????????? ??? ???????? ???????? (????????????? ??? ?????????) ? ??????-???? ??????? ?? ?????? ???-??????. ????? ????, ?? ?????? ????? ??? ?????? ??????? ??????? ?????.

???????:

? mod_rewrite ??????? ??????????. ?? ????? ?????? ?????????? ?? ?????? ??????? ?????????????? ???? URL ???? /~user/anypath ? URL ???? http://newserver/~user/anypath.>

RewriteEngine on
RewriteRule   ^/~(.+)  http://newserver/~$1  [R,L]

????????????????? ???????? ????????

????????:

????????? ????? ? ???????? ????????????? ?????? ?????????? ????????????????? ????? ???????? ?????????, ?.?. ?????? ???????? ??????? ????????? ? ?????-???? ???????????, ??????? ??? ??????? ?????????? ? ?????? ????? ????? ????????????. ???????, /~foo/anypath ????? ???? /home/f/foo/.www/anypath ? ?? ????? ??? /~bar/anypath ????? ???? /home/b/bar/.www/anypath.

???????:

????? ???????? ?????? ? URL ????? ? ???????????? ? ????????????? ??????, ?? ?????????? ????????? ????? ??????:

RewriteEngine on
RewriteRule   ^/~(([a-z])[a-z0-9]+)(.*)  /home/$2/$1/.www$3

????????????? ???????? ???????

????????:

??? ????????????? ????? ??????? ??????: ????????? ????, ????? ?????????? ???????????? RewriteRules ? ????????? ?????????(.htaccess) ??? ???? ????? ???????? ?????????? ??? ?????? ? ??????? ????, ??? ???? ?? ? ?????????, ????????? ?????? ??????? ?? ????????? ??? ????????????. ???????????: net.sw ??? ??? ????? ???????? ????????????????? ?? ??? Unix, ??????? ? ????? ???????? ? 1992. ??? ???? ??? ???????????? ? ????? ? ??????, ?????? ??? ?????? ???????????? ?????, ? ????????? ????? ? ????? ??????? ????????? ? ??????? ??????????????? ? ??????? ?????? ???. ?????? ?????? ??? ????? ????????? ?????????? ?? ??????? ? ?????? ???????? ???????? ?????????, ??? ? ???????? ??? ????????????:

drwxrwxr-x   2 netsw  users    512 Aug  3 18:39 Audio/
drwxrwxr-x   2 netsw  users    512 Jul  9 14:37 Benchmark/
drwxrwxr-x  12 netsw  users    512 Jul  9 00:34 Crypto/
drwxrwxr-x   5 netsw  users    512 Jul  9 00:41 Database/
drwxrwxr-x   4 netsw  users    512 Jul 30 19:25 Dicts/
drwxrwxr-x  10 netsw  users    512 Jul  9 01:54 Graphic/
drwxrwxr-x   5 netsw  users    512 Jul  9 01:58 Hackers/
drwxrwxr-x   8 netsw  users    512 Jul  9 03:19 InfoSys/
drwxrwxr-x   3 netsw  users    512 Jul  9 03:21 Math/
drwxrwxr-x   3 netsw  users    512 Jul  9 03:24 Misc/
drwxrwxr-x   9 netsw  users    512 Aug  1 16:33 Network/
drwxrwxr-x   2 netsw  users    512 Jul  9 05:53 Office/
drwxrwxr-x   7 netsw  users    512 Jul  9 09:24 SoftEng/
drwxrwxr-x   7 netsw  users    512 Jul  9 12:17 System/
drwxrwxr-x  12 netsw  users    512 Aug  3 20:15 Typesetting/
drwxrwxr-x  10 netsw  users    512 Jul  9 14:08 X11/

? ???? 1996 ? ????? ??????? ???? ????? ????????????? ????? ???? ????? ???????? ???-?????????. «????????» ??????? ????? ??? ? ????? ?????????? ????????? ??? ?? ?????? ???????????? ????? ?? ???????? ????? ??????. ? «????????» ?????? ??? ? ?? ????? ?????? ???????? ?????? ???? ???????? — ???? ?? ???????? ????????? CGI ??????? ?? ?? ????. ??????? ?????? ??? ??????????????? ????????? ????? ?????? ???? ???? ???????? ????? ? ????? FTP, ? ? ?? ????? ??????? ??? ????? ???? ??? ??? CGI ????.

???????:

??????? ??????? ?? 2-? ??????: ?????? ??? ????? CGI ???????? ??????? ??????? ??? ???????? ?? ???? ?? ???? ??????? ?????????. ? ???????? ?? ? /e/netsw/.www/ ? ????????? ????:

-rw-r--r--   1 netsw  users    1318 Aug  1 18:10 .wwwacl
drwxr-xr-x  18 netsw  users     512 Aug  5 15:51 DATA/
-rw-rw-rw-   1 netsw  users  372982 Aug  5 16:35 LOGFILE
-rw-r--r--   1 netsw  users     659 Aug  4 09:27 TODO
-rw-r--r--   1 netsw  users    5697 Aug  1 18:01 netsw-about.html
-rwxr-xr-x   1 netsw  users     579 Aug  2 10:33 netsw-access.pl
-rwxr-xr-x   1 netsw  users    1532 Aug  1 17:35 netsw-changes.cgi
-rwxr-xr-x   1 netsw  users    2866 Aug  5 14:49 netsw-home.cgi
drwxr-xr-x   2 netsw  users     512 Jul  8 23:47 netsw-img/
-rwxr-xr-x   1 netsw  users   24050 Aug  5 15:49 netsw-lsdir.cgi
-rwxr-xr-x   1 netsw  users    1589 Aug  3 18:43 netsw-search.cgi
-rwxr-xr-x   1 netsw  users    1885 Aug  1 17:41 netsw-tree.cgi
-rw-r--r--   1 netsw  users     234 Jul 30 16:35 netsw-unlimit.lst

?????????? DATA/ ???????? ??????????????? ????????? ?????????, ?.?. ????????? ?????? net.sw ? ?????????????, ????? ?? ???????, ???????? ?????????? ????? rdist. ?????? ????? ???????? ????????: ??? ??????? ??? ??? ????????? ?????? ? ???? ??????????????? ?????? URL? ?? ????? ?????? ??????? DATA/ ?? ???????????? ??? ??????? ??????????????? CGI ???????? ??? ?????? URL. ??? ? ???????: ??????? ? ???????? ????????? ? ???????????????? ???? ???????? ? DocumentRoot ??????? ??? ?????????????? ???????????? URL /net.sw/ ?? ?????????? ???? /e/netsw:

RewriteRule  ^net.sw$       net.sw/        [R]
RewriteRule  ^net.sw/(.*)$  e/netsw/$1

?????? ??????? ????????????? ??? ???????? ? ??????? ??????????? ??????????? ????! ?????? ??????? ?????? ?????? ??????????????. ? ????? ???????????? ??????????? ???????????????? ??????? ????????? ? ???????????????? ????? ???????? /e/netsw/.www/.wwwacl:

Options       ExecCGI FollowSymLinks Includes MultiViews

RewriteEngine on

#  ???????????? ??????? /net.sw/
RewriteBase   /net.sw/

#  ??????? ?? ?????????????? ??? ??????? ? ????????? ???????? ??
#  ??????????? cgi ??????
RewriteRule   ^$                       netsw-home.cgi     [L]
RewriteRule   ^index.html$            netsw-home.cgi     [L]

#  ???????? ??????????? ?????
#  ??????? ??????????? ??? ?? ??????? ? ????????????
RewriteRule   ^.+/(netsw-[^/]+/.+)$    $1                 [L]

#  ? ?????? ?? ?????? ???????? ??? ????????? ??????
RewriteRule   ^netsw-home.cgi.*       -                  [L]
RewriteRule   ^netsw-changes.cgi.*    -                  [L]
RewriteRule   ^netsw-search.cgi.*     -                  [L]
RewriteRule   ^netsw-tree.cgi$        -                  [L]
RewriteRule   ^netsw-about.html$      -                  [L]
RewriteRule   ^netsw-img/.*$           -                  [L]

#  ??? ????????? ???????? ???????????? ? ???????????
#  ?????? cgi ????????
RewriteRule   !^netsw-lsdir.cgi.*     -                  [C]
RewriteRule   (.*)                     netsw-lsdir.cgi/$1

????????? ?????? ?? ?????????????:

  1. ???????? ???? L (?????????) ? ?????????? ???? ??????????? ('-') ? 4-? ?????
  2. ???????? ?????? ! (??) ? ???? C (???????) ? ?????? ??????? ????????? ?????
  3. ???????? ?????? ??????????????? ??? ??????? ? ????????? ???????

?? NCSA imagemap ? Apache mod_imap

????????:

????? ?? ????????? ? ???-??????? NCSA ?? ????? ??????????? ???-?????? Apache ????? ?????? ????? ????? ???? ??????? ??? ??????????????. ??????? ??? ????? ????? ????????, ???????????? ?????? ????????? NCSA imagemap ???????? ??? Apache ? ????? ??????? mod_imap . ???????? ? ???, ??? ???? ????? ??????????? ??????? ????????? ?? ????????? imagemap ????? /cgi-bin/imagemap/path/to/page.map. ? Apache ?????????? ????????? ?????? /path/to/page.map.

???????:

?? ?????????? ?????????? ??????? ??? ???????? ?? ???? ???????? ??? ???? ????????:

RewriteEngine  on
RewriteRule    ^/cgi-bin/imagemap(.*)  $1  [PT]

????? ??????? ?????? ??? ? ????? ????????

????????:

?????? ?????????? ????????? ???-??????? ?????? ???????? ?????? ??? ? ????? ????????. ????? ??? ?? ??????? ?? MultiViews ?? ?????? ???????.

???????:

?? ????? ????? ????? ?????? ??????? ???? ????? ? ?????????.

RewriteEngine on

#   ??-?????? ?????????? ????? ??? ? ????????? ?????/...
#   ...? ???? ????? ?? ??????????? ????? ? ????? ? ????????:
RewriteCond         /your/docroot/dir1/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir1/$1  [L]

#   ??-?????? - ?????????? ????? ??? ? pub/...
#   ...? ???? ????? ?? ??????????? ????? ? ????? ? ????????:
RewriteCond         /your/docroot/dir2/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir2/$1  [L]

#   ????? ?????????? ??? ?????? ???????? Alias ??? ScriptAlias,
#   ? ?.?.
RewriteRule   ^(.+)  -  [PT]

????????? ?????????? ????????? ? ???????????? ? ??????? URL

????????:

???????? ?? ?????? ??????? ?????????? ? ??????? ????? ????????? ? ???????????? URL ??? ?? ???????????. ?????? ?? ???????, ?????? ??? ????????? ???? ??????????, ???????????? CGI ?????????? ???? ???????.

???????:

?? ?????????? ??????? ??? ???? ????? ???????? ?????????? ? ??????? ? ??????? ?? ? ?????????? ????????? ??????? ????? ????? ???? ???????????? ? XSSI ??? CGI. ????? ??????? URL /foo/S=java/bar/ ????????????? ? /foo/bar/ ? ?????????? ????????? STATUS ??????????????? ? «java».

RewriteEngine on
RewriteRule   ^(.*)/S=([^/]+)/(.*)    $1/$3 [E=STATUS:$2]

??????????? ????? ?????????????

????????:

??????????? — ?? ?????? ????????????? ?????? www.username.host.domain.com ??? ??????? ????????????? ????? ?????? DNS ???? A ?? ??? ?? ????? ?????? ? ??? ????? ???? ??????????? ?????? ?? ???? ??????.

???????:

??? ???????? HTTP/1.0 ??????? ???, ?????? ??? ???????? HTTP/1.1 ??????? ???????? HTTP ????????? Host: ?? ????? ???????????? ????????? ????? ?????? ??? ?????????????? http://www.username.host.com/anypath> ?? ?????????? ???? /home/username/anypath:

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^www.[^.]+.host.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^www.([^.]+).host.com(.*) /home/$1$2

??????????????? ???????? ????????? ??? ???????

????????:

?? ????? ????????????? URL ???????? ????????? ?? ?????? ???-?????? www.somewhere.com ????? ????????????? ???????????? ?? ??????????? ?????????? ?????? ourdomain.com. ??? ?????? ???????????? ? ????????? ??????????? ??????.

???????:

?????? ??????? ?? ???????????????:

RewriteEngine on
RewriteCond   %{REMOTE_HOST}  !^.+.ourdomain.com$
RewriteRule   ^(/~.+)         http://www.somewhere.com/$1 [R,L]

??????????????? ?????????????? URL ?? ?????? ???-??????

????????:

???????? ????? ?????????? ?????? ?? URL ??????????????? — ??? ??? ????????????? ?????????????? ??????? ? ??????? ? ?? ?????? B. ?????? ??? ???????? ????? ErrorDocument CGI-??????? ?? Perl, ?????? ? ??????? mod_rewrite ???? ???? ???????. ???????? ??????, ??? ??? ????? ??????????? ??? ???????????? ErrorDocument CGI-???????!

???????:

?????? ??????? ????? ?????? ?????????????????? ?????? ??????? ???????? ? ??????? ?????? ?? ??????:

RewriteEngine on
RewriteCond   /your/docroot/%{REQUEST_FILENAME} !-f
RewriteRule   ^(.+)                             http://webserverB.dom/$1

???????? ????? ? ???, ??? ??? ????? ???????? ?????? ??? ??????? ??????????? ?????? DocumentRoot . ????? ??? ?? ?????? ???????? ?????? ??????? (???????? ??? ? ??? ?????????? ????????? ??????????, ? ?.?.) ???? ?????? ???????:

RewriteEngine on
RewriteCond   %{REQUEST_URI} !-U

RewriteRule   ^(.+)          http://webserverB.dom/$1

????? ???????????? ??????????? mod_rewrite — URL look-ahead(???????? ??????). ? ?????????? ??? ????? ???????? ??? ???? ????? URL ? ? ???? ?? ??? ?????????. ?????? ??? ??????? ?????????????????? ???-???????, ?????? ??? ??? ??????? ??????? ???????????? ????? ?????? ??????????? ??????????. ???????, ???? ??? ???-?????? ????? ?????? ?????????, ??????????? ???? ???????. ???? ??? ????????? ??????, ??????????? ?????? ??? ????? ErrorDocument CGI-???????.

??????? ????????

????????:

?????? ??? ????? ?????? ???????? ??? URL (??????? ????????? ????????? ????????) ??? ???????????????. ?????? ?????????? ??????? URL ???? Apache ????? ??????? ? ?????, ?.?. ? URL ???? «url#anchor». ?? ?? ?????? ??? ??????????????? ???????????? ??? ?????????? ? mod_rewrite ?????? ??? ??????? Apache uri_escape() ????? ???????? ?? ????????? ??????. ??? ?? ????? ??????? ???????? ?????? URL?

???????:

?? ?????? ???????????? ??? ? ????????? ????????? NPH-CGI ?????? ??????? ?????? ???????? ?? ???? ??????. ?????? ??? ????? ?? ???????? ????????? (NPH=non-parseable headers). ??????? ?? ?????? ????? URL scheme xredirect: ? ????????? ?????? ????????????????? ????? ??????? (?????? ???? ????? ?? ????????? ???????? ):

RewriteRule ^xredirect:(.+) /path/to/nph-xredirect.cgi/$1 
            [T=application/x-httpd-cgi,L]

??? ?????????? ??? URL ???????????? ? xredirect: ????? ????????? nph-xredirect.cgi. ? ??? ????????? ???????? ???????? ??? :

#!/path/to/perl
##
##  nph-xredirect.cgi -- NPH/CGI script for extended redirects
##  Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
##

$| = 1;
$url = $ENV{'PATH_INFO'};

print "HTTP/1.0 302 Moved Temporarilyn";
print "Server: $ENV{'SERVER_SOFTWARE'}n";
print "Location: $urln";
print "Content-type: text/htmln";
print "n";
print "<html>n";
print "<head>n";
print "<title>302 Moved Temporarily (EXTENDED)</title>n";
print "</head>n";
print "<body>n";
print "<h1>Moved Temporarily (EXTENDED)</h1>n";
print "The document has moved <a HREF="$url">here</a>.<p>n";
print "</body>n";
print "</html>n";

##EOF##

??? ????????????? ??? ??????? ??? ???? ????? ?????? ??????????????? ?? ??? URL schemes, ?.?. ??????? ??, ???????, ?? ????? ??????????? mod_rewrite . ??? ??????? ?? ?????? ?????? ????? ????????????? news:newsgroup ?????

RewriteRule ^anyurl  xredirect:news:newsgroup
?????????: ?? ?? ?????? ???????????? [R] ??? [R,L] ? ??????????????? ????????? ?????? ??? xredirect: ?????, ?????? ???? ????????? ????? ??????????? ???????? «pipe through» ??????? ????????? ????.

????????????? ??? ??????? ? ???????

????????:

?? ?????? ????? ???????? ???? ??? CPAN (Comprehensive Perl Archive Network) ????????????? ?? ?????? http://www.perl.com/CPAN? ????? ???????? ???????? ?? ???? ?? ?????????? FTP ???????? ?? ????? ????, ?? ??????? ??????????? ??????? CPAN ? ??? ?????????????? ??????????? ????? ? ??????????????? ?????????????? ???????. ? ???????????????? ??? ????? ???? ??????? ?????????????????? ??????? ??????? ? FTP. ???? CPAN ???????? ?? CGI ????????, ??? ????? ??????????? ??????? ??????? ? ??????? mod_rewrite ?

???????:

??? ?????? ??????? ??? ??????? ? ?????? 3.0.0 mod_rewrite ????? ????? ???????????? «ftp:» ??????? ??? ??????????. ? ??????, ???????????? ?????????????? ????? ???? ??????? ????? ?????????????? ??????? ?????????????? RewriteMap ????? ????? ???????? ??????, ??? ??????????? ???????. ? ??????? ?????? ??????? ???????? ?? ????? ???????????? ???? ????? ???????? ?????? ? ???????? ????? ??? ?????? ? ????? ????????????? ??????? ???????????????????.

RewriteEngine on
RewriteMap    multiplex                txt:/path/to/map.cxan
RewriteRule   ^/CxAN/(.*)              %{REMOTE_HOST}::$1                 [C]
RewriteRule   ^.+.([a-zA-Z]+)::(.*)$  ${multiplex:$1|ftp.default.dom}$2  [R,L]

##
##  map.cxan -- ?????? ??????????????????? ??? CxAN
##

de        ftp://ftp.cxan.de/CxAN/
uk        ftp://ftp.cxan.uk/CxAN/
com       ftp://ftp.cxan.com/CxAN/
 :
##EOF##

????????? ? ??????????? ?? ???????

????????:

????? ????? ????????? ?????? ???? ?????????? ?????????? ?? ??????? ????? ??????????? ??? ??? ?????????? CGI ??????? ??????? ?????????? ????????? ?? ??????????? ????????. ??? ??? ????? ???? ??????? ????? mod_rewrite ?

???????:

???? ????? ?????????? ????????? TIME_xxx ??? ??????? ?????????. ? ?????? ?? ???????????? ??????????????????? ????????? ??? ????????? <STRING, >STRING ? =STRING ?? ????? ??????????? ????????? ????????? ?? ???????:

RewriteEngine on
RewriteCond   %{TIME_HOUR}%{TIME_MIN} >0700
RewriteCond   %{TIME_HOUR}%{TIME_MIN} <1900
RewriteRule   ^foo.html$             foo.day.html
RewriteRule   ^foo.html$             foo.night.html

??? ?????? ?????????? foo.day.html ??? ??????? URL foo.html ? 07:00 ?? 19:00 ? ? ?????????? ????? ?????????? foo.night.html. ?????? ??????? ???? ??? ?????-???? ?????????...

???????? ????????????? ??? ???????? ? YYYY ?? XXXX

????????:

??? ???????? ??????? URL ??????? ???????????? (??? ??? ????????????? ??????????) ????? ???????? ????????? document.YYYY ? ???????? document.XXXX, ?.?. ????? ?????????????? ???? .html ?????? ? ????? .phtml?

???????:

?? ?????? ????????? ??? ????????? ??? ????? ? ????????? ????????????? ?????? ??????????. ???? ??? ??????????, ?? ???????? ??? ??? ?????????, ????? ?? ?????????????? URL ? ??? ???????? ??????????????.

#   ????? ?????? ??? ???????? ????????????? ???
#   ????????? ??? document.html ? document.phtml
#   ????? ? ?????? ????? ????? document.phtml ??????????
#   ?????? ?? ???????? document.html
RewriteEngine on
RewriteBase   /~quux/
#   ????????? ??????? ???, ? ?????????? ???
RewriteRule   ^(.*).html$              $1      [C,E=WasHTML:yes]
#   ?????? ???????? ?? document.phtml ???? ?? ??????????
RewriteCond   %{REQUEST_FILENAME}.phtml -f
RewriteRule   ^(.*)$ $1.phtml                   [S=1]
#   ????? ?????? ????? ?? ?????????? ????????
RewriteCond   %{ENV:WasHTML}            ^yes$
RewriteRule   ^(.*)$ $1.html

?????????? ???????????

?? ??????? ? ?????? (??????????)

????????:

??????????? ??? ?? ??????? ????????????? ???????? bar.html ? foo.html ? ?????? ????? ??? ???????? ????????????? ??????? ????????? ? ?????? URL. ? ???????????????? ?? ????? ????? ???????????? ???????????? ?????? URL ???? ?? ?????? ??? ???????? ???? ?????????????.

???????:

?? ???????????? ?????? URL ?? ????? ????? ?????????? ???????? ????? ????????? ????????:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo.html$  bar.html

?? ??????? ? ?????? (???????)

????????:

????? ??????????? ??? ?? ??????? ????????????? ???????? bar.html ? foo.html ? ????? ?????? ??? ???????? ????????????? ??????? ????????? ? ?????? URL. ??????, ? ???? ??? ?? ?????????? ???????????? ???????????? ?????? URL ?????? ???? ????? URL, ?.?. ???????? ?????? ?? ????????? ????? ?????? ??????????.

???????:

?? ?????????? HTTP ???????? ?? ????? URL ??????? ???????? ? ? ?????????? ? ?????????(? ???????? ??????) ? ????? ??????? ??? ????? ????????????:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo.html$  bar.html  [R]

?????????? ????????? ?? ????????

????????:

??????, ?? ??????? ???? ??? ?????? ??????? ???????? ?????? ?????????? ???????????? ???????????????? ??? ??????????? ???????? ??????????, ?.?. ??? ?????? ????? ???????? ?????? ?????? ??? ????????? ?????? Netscape, ??????????? ??? ????????? Lynx ? ????????????? ??? ???? ??????.

???????:

?? ?? ????? ???????????? content negotiation ?????? ??? ???????? ?? ?? ???????????? ???? ??? ? ???? ?????. ?????? ????? ?? ?????? ???????????? HTTP ????????? «User-Agent». ????????? ??????? ?????? ?????????: ???? HTTP ????????? «User-Agent» ?????????? ? «Mozilla/3», ???????? foo.html ????????????? ? foo.NS.html ? ???????? ????????????. ???? ??????? «Lynx» ??? «Mozilla» ?????? 1 ??? 2 URL ?????????? foo.20.html. ??? ????????? ???????? ???????? ???????? foo.32.html. ??? ???????? ????????? ??????? ????????:

RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/3.*
RewriteRule ^foo.html$         foo.NS.html          [L]

RewriteCond %{HTTP_USER_AGENT}  ^Lynx/.*         [OR]
RewriteCond %{HTTP_USER_AGENT}  ^Mozilla/[12].*
RewriteRule ^foo.html$         foo.20.html          [L]

RewriteRule ^foo.html$         foo.32.html          [L]

???????????? ???????

????????:

??????????? ??? ???? ???????? ???????? ?? ????????? ?????? ? ?? ????? ?????? ?? ? ???? ???????????? ????(????). ??? FTP ???????? ?? ?? ???????????? ????????? ??????? ??????? ? ???????????????? ????????? ???????????? ????? ????????? ?????? ?? ????????? ??????. ??? ???-??????? ?? ????? ?? ???????????? ????????? webcopy ??????? ?????? ??????? ???? ?? HTTP. ?????? ??? ??? ?????????? ????? ???? ??????? ?????????: ????????? ????? ????????? ?????? ?????????, ????????? ????? ?? ????????? ??? ?????????. ???? ?? ??????? ????? ???? ?? ??????? ???? ?? ??????????? ?????? ???? ?????? ???????????? ?????, ??? ??????????? ?? ??????? ??????? ???? ?????????. ?????? ????? ?? ????? ???????????? ??????? ? ?????????????? ??????????? ?????? ????? ??? ?????????? (?????????? ?????? ?? ????????? ???????).

???????:

??? ??????????? ???? ??????? ?? ????????? ????????? ???????? ??? ???? ????????? ????????? ???? ? ???? ???-???????????? ????????? Proxy Throughput ????? (???? [P]):

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^hotsheet/(.*)$  http://www.tstimpreso.com/hotsheet/$1  [P]
RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^usa-news.html$   http://www.quux-corp.com/news/index.html>  [P]

???????? ???????????? ???????

????????:
...
???????:
RewriteEngine on
RewriteCond   /mirror/of/remotesite/$1           -U
RewriteRule    http://www.remotesite.com/(.*)$ /mirror/of/remotesite/$1

????????? ????????????? ?????? ?? Intranet

????????:

??? ?????? ?????? ???????????? ?????????????? (????????) Internet ???-??????? (www.quux-corp.dom), ? ???????????????? ???????? ? ??????????? ??????? ?????????????? ?? (??????????) Intranet ???-??????? (www2.quux-corp.dom) ??????? ???????? firewall'??. ????? ? ???, ??? ?? ??????? ???-??????? ?? ???????? ??????????? ?????? ?? ???? ? ??????????? ???????.

???????:

???????, ?? ?????? ????????? ??? ??? firewall ??? ??? ???????? ?????????? ???-?????? ? ??? ?????? ???????? ???-??????? ????????? ???????? ? ???? ??????. ??? firewall'a ? ??????????? ??????? ?? ????? ?? ??? ??????? ???????????????? ????? ???????? ??? firewall ??????? ?????:

ALLOW Host www.quux-corp.dom Port >1024 --> Host www2.quux-corp.dom Port 80


DENY Host * Port * --> Host www2.quux-corp.dom Port 80

?????? ?????????? ??? ????? ??????????????? ?????? ??????????. ?????? ?? ????? ???????????? ????????? mod_rewrite ??????? ??????????? ????????????? ?????? ? backend ??????? ????? ??????:

RewriteRule ^/~([^/]+)/?(.*)          /home/$1/.www/$2
RewriteCond %{REQUEST_FILENAME}       !-f

RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule ^/home/([^/]+)/.www/?(.*) http://www2.quux-corp.dom/~$1/pub/$2 [P]

???????????? ????????

????????:

??????????? ??? ?? ????? ??????? ???????????? ???????? ??? ???????? www.foo.com ?? www[0-5].foo.com (????? 6 ????????). ??? ??? ???????? ????????

???????:

???? ????? ????????? ??????? ???? ????????. ?? ??????? ??????? ????????????? ?????????? ?? DNS ??????? ? ????????????? ? ??????? mod_rewrite :

  1. ??????????? DNS

    ????? ??????? ?????? ??? ???????????? ???????? ??? ????????????? ??????? ???????????? DNS ? DNS ??????? BIND. ?????? ??????????????? www[0-9].foo.com ??? ?????? ? ????? DNS ??????? ? ?????????????? ??????? ???? A(address) ?.?.

    www0   IN  A       1.2.3.1
    www1   IN  A       1.2.3.2
    www2   IN  A       1.2.3.3
    www3   IN  A       1.2.3.4
    www4   IN  A       1.2.3.5
    www5   IN  A       1.2.3.6
    

    ?????, ????????????? ???????? ????????? ??????:

    www    IN  CNAME   www0.foo.com.
           IN  CNAME   www1.foo.com.
           IN  CNAME   www2.foo.com.
           IN  CNAME   www3.foo.com.
           IN  CNAME   www4.foo.com.
           IN  CNAME   www5.foo.com.
           IN  CNAME   www6.foo.com.
    

    ???????? ??? ??? ??????? ????????????, ?????? ? ???????????????? ??? ??????????? ??????????? BIND ? ????? ???? ???????????? ????? ????????. ??????, ??????, ????? ?????????? ?????????? www.foo.com , BIND ?????? www0-www6 — ?????? ?????? ?????/????????? ?????? ??? ???????. ????? ??????? ??????? ?????????????? ?? ?????? ???????? . ?????? ???????? ??? ??? ?? ????????? ????? ???????????? ????????, ?????? ??? ?????????? ? ?????????? ???? DNS ?????????? ??????? ????????? ???? ? ????, ??????? ??? ?????? ?????????? ????? www.foo.com ???????? ?? ?????????? wwwN.foo.com, ??? ??????????? ??????? ????? ?????? ?? ??? ?????????? ???????? ??? wwwN.foo.com. ?????? ???????? ????????? ??????? , ?????? ??? ????? ????? ???????? ????????????? ?????????????? ?? ?????? ???-???????.

  2. ???????????? ???????? ? ??????? DNS

    ??????? ????? ???????????? ???????? ?????????? ?? DNS ??? ????????????? ????????? lbnamed ??????? ????? ???? ??????? ??  http://www.stanford.edu/~schemers/docs/lbnamed/lbnamed.html>. ??? ????????? ?? Perl 5 ? ?????? ? ???????????????? ??????????, ???????????? ????????? ???????????? ???????? ? ?????????????? DNS.

  3. ??????????? Proxy

    ? ???? ???????? ?? ?????????? mod_rewrite ? ??? proxy ???????. ??????? ?? ?????????? www0.foo.com ????????? www.foo.com ??? ?????? ???????

    www    IN  CNAME   www0.foo.com.
    

    ?????? ? DNS. ????? ?? ?????????? www0.foo.com ?????? ?? proxy ??????, ?.?. ?? ??????????? ??? ?????? ??? ????? ??? ??????? URL ?????? ???????????? ????? ?????????? proxy ?? ???? ?? 5-?? ?????? ???????? (www1-www5). ??? ????? ?? ??????? ?????? ????? ???????? ??????? ??????????????? ?? ???????? lb.pl ???????????? ???????? ??? ???? URL.

    RewriteEngine on
    RewriteMap    lb      prg:/path/to/lb.pl
    RewriteRule   ^/(.+)$ ${lb:$1}           [P,L]
    

    ????? ?? ????? lb.pl:

    #!/path/to/perl
    ##
    ##  lb.pl -- ?????? ???????????? ????????
    ##
    
    $| = 1;
    
    $name   = "www";     # ???? ??? ????? ?????
    $first  = 1;         # ?????? ?????? (????? ?? 0, ?????? ??? 0 ??? ? ???? ???? ??????)
    $last   = 5;         # ????????? ?????? ? ?????
    $domain = "foo.dom"; # ???????? ???
    
    $cnt = 0;
    while (<STDIN>) {
        $cnt = (($cnt+1) % ($last+1-$first));
        $server = sprintf("%s%d.%s", $name, $cnt+$first, $domain);
        print " http://$server/$_";;
    }
    
    ##EOF##
    
    ????????? ?????????: ?????? ??? ???????? ??????? ??? www0.foo.com ???-??? ??????????? ????? ????????????? , — ?? ??????????, ?????? ?????? ???????? proxy ?????????! ??? SSI, CGI, ePerl, ? ?.?. ???????, ????????? ??????????? ??????? ????????. ??? ???????? ????.
  4. ??????????/TCP Round-Robin

    ??? ???? ?????? ???? ????? ????????? ????????? ???????. Cisco ????? ?????????? ?????????? LocalDirector ??????? ?????????? ???????????? ???????? ?? ?????? TCP/IP. ? ???????????????? ??? ????????? ??? ???????????? ????? ???????? ????? ???-?????????. ???? ? ??? ???? ?????????? ????? ? ??? ????????????? ????? ?????????????????????? ???????, ??????????? ???? ???????.

???????? Proxy

????????:
...
???????:
##
##  apache-rproxy.conf -- ???????????? Apache ??? ????????????? ????????? Proxy
##

#   ??? ???????
ServerType           standalone
Listen               8000
MinSpareServers      16
StartServers         16
MaxSpareServers      16
MaxClients           16
MaxRequestsPerChild  100

#   ????????? ???????????????? ???????
KeepAlive            on
MaxKeepAliveRequests 100
KeepAliveTimeout     15
Timeout              400
IdentityCheck        off
HostnameLookups      off

#   ???? ??? ??????? ??????
PidFile              /path/to/apache-rproxy.pid
LockFile             /path/to/apache-rproxy.lock
ErrorLog             /path/to/apache-rproxy.elog
CustomLog            /path/to/apache-rproxy.dlog "%{%v/%T}t %h -> %{SERVER}e URL: %U"

#   ?????????????? ????
ServerRoot           /tmp
DocumentRoot         /tmp
CacheRoot            /tmp
RewriteLog           /dev/null
TransferLog          /dev/null
TypesConfig          /dev/null
AccessConfig         /dev/null
ResourceConfig       /dev/null

#   ???????? ???????? ?????? ? ????????????
<Directory />
Options -FollowSymLinks -SymLinksIfOwnerMatch
AllowOverride None
</Directory>

#   ???????? ????????? ??? ???????? ????????? proxy
<Location /apache-rproxy-status>
SetHandler server-status
</Location>

#   ???????? ???????? URL ??????????????
RewriteEngine        on
RewriteLogLevel      0

#   ?????????? ????????????? ?????? ?????????? ?? ???????? ??????? ? ???????
#   mod_rewrite ??????????? ???????? ?????-???? ?? ???
RewriteMap     server  rnd:/path/to/apache-rproxy.conf-servers

#   ???????? ???? ??? ???????? ????????? ?????????????? ????????
#   ? ???????? ????, ??? ????? ?? ?????????? ??? proxy ????? ??? ?????
RewriteRule    ^/apache-rproxy-status.*  -  [L]
RewriteRule    ^(http|ftp)://.*          -  [F]

#   ?????? ???????? ????????? ??????? ??? ?????????? ????? URL
RewriteRule    ^/(.*.(cgi|shtml))$  to://${server:dynamic}/$1  [S=1]
RewriteRule    ^/(.*)$               to://${server:static}/$1

#   ? ?????????? ??????????????? URL ????????? ???
#   ????? proxy-??????
RewriteRule    ^to://([^/]+)/(.*)    http://$1/$2   [E=SERVER:$1,P,L]

#   ? ??????????? ??? ??? ?????? ??????? ?????????
#   ????? ??? ?????? ????? ??????????? ???????...
RewriteRule    .*                    -              [F]

#   ???????? Proxy-?????? ??? ???????????
ProxyRequests        on
NoCache              *

#   ????????????? ???????? ??????????? URL ??? ??????? ??? ?????????
ProxyPassReverse  /  http://www1.foo.dom/
ProxyPassReverse  /  http://www2.foo.dom/
ProxyPassReverse  /  http://www3.foo.dom/
ProxyPassReverse  /  http://www4.foo.dom/
ProxyPassReverse  /  http://www5.foo.dom/
ProxyPassReverse  /  http://www6.foo.dom/

##
##  apache-rproxy.conf-servers -- ??????? ?????? Apache/mod_rewrite
##

#   ?????? backend ???????? ??????? ??????????? ???????????
#   ???????? (HTML ????? ? ????????, ? ?.?.)
static    www1.foo.dom|www2.foo.dom|www3.foo.dom|www4.foo.dom

#   ?????? backend ???????? ??????? ??????????? ???????????
#   ??????????????? ???????? (CGI ????????? ??? mod_perl ???????)
dynamic   www5.foo.dom|www6.foo.dom

????? ??? MIME, ????? ??????

????????:

? ???? ???? ????? ???????? CGI ????????. ?????? ?? ?????????? ?????? ?????????, ??????? ?????? ???-??????? ?? ?? ??????????. ???? ??????? Action handler Apache'? ??? MIME-????? ????????? ?????? ?????, ????? CGI ????????? ?? ????????? ? ??????????? URL (? ???????????????? PATH_INFO ? QUERY_STRINGS) ??? ??? ???????? ??????. ???????, ??????? ???????? ????? ??? ????? ? ??????????? .scgi (??? ?????????? CGI) ??????? ????? ?????????????? ?????????? ?????????? cgiwrap. ???????? ????? ??????????? ? ??? ??? ??? ????? ?????? ?? ?????????? ?????????? URL (??. ????) ? ? ?????-???? ???? ??????????? ?????? ???????? ????????? ????????????? ????? URL /u/user/foo/bar.scgi. ?????? cgiwrap ??????? URL ? ???? /~user/foo/bar.scgi/. ????????? ????????? ?????? ??? ????????:

RewriteRule ^/[uge]/([^/]+)/.www/(.+).scgi(.*) ...
... /internal/cgi/user/cgiwrap/~$1/$2.scgi$3  [NS,T=application/x-http-cgi]

??? ??????????? ??? ? ??? ???? ????????? ???????? ????????: wwwlog (???????????? access.log ??? ????????? URL ? wwwidx (??????????? Glimpse ?? ????????? URL ). ?? ?????? ???????????? ??????? URL ??? ???? ???????? ????? ??? ????? ??? ????? ??????? ??? ?????? ????????. ?????? ?????? ??? ??????, ?????? ??? ??? ??? ????? ????????????? ?? ??? ????????, ?.?. ?????? ?? ?? ????????? ????????? swwidx ?? /u/user/foo/ ????? ??????

/internal/cgi/user/swwidx?i=/u/user/foo/

??????? ??????. ??? ??? ?? ?????? ?????? ????????? ? ?????????????? ??????? ? ??????????????? CGI ?????? ???????????. ? ?????? ???? ??? ?????????? ?????????????? ??? ???????, ?? ?????? ????? ??????? ????? ????????? ???????????.

???????:

??????? ? ???? ?????? ??? ??????? ????? ??????????? ?????? URL ??????? ????????????? ???????? ? ?????? ??????? CGI. ??????????? ???:

RewriteRule   ^/([uge])/([^/]+)(/?.*)/*  /internal/cgi/user/wwwidx?i=/$1/$2$3/
RewriteRule   ^/([uge])/([^/]+)(/?.*):log /internal/cgi/user/wwwlog?f=/$1/$2$3

?????? ??????????? ??? ?????? /u/user/foo/ ????????? ??????

HREF="*"

??????? ????????? ????????????? ???????????????? ?

/internal/cgi/user/wwwidx?i=/u/user/foo/

?? ?? ????? ???????? ? ?????? CGI ????????? ??? ??????? ? ????? ????? ???????????? ??????????? :log.

?? ??????? ? ????????

????????:

??? ????? ???????????????? ??????????? ???????? foo.html ? ?? ???????????? ??????? foo.cgi ?????????? ???????, ?.?. ??? ????? ?? ??????? ?? ???????????? ?? ???????? ?????.

???????:

?? ?????? ?????????????? URL ?? CGI-?????? ? ???????????? MIME-??? ??? ????? ??? ????????????? ???????? ??? CGI-??????. ????? ??????? ?????? ? /~quux/foo.html ????????? ???????? ? ?????? /~quux/foo.cgi.

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo.html$  foo.cgi  [T=application/x-httpd-cgi]

??????????? ?????????? ?? ????

????????:

????? ??????????????? ????????????? ???? ??? ???????????: ??????????? ????????? ?????? ?????????? ????????????? ????????, ?.?. ???????? ??????? ?????? ???????????? ??? ????? ??????????? (??????????? ?? ???????? ??????? ? ????? ???????????? ?? ???????), ?????? ??? ?????? ???? ??????????? ?????????????? ???-???????? ???? ??? ??????????? ? ???????? ???????. ????? ??????? ?? ?????? ????? ???????? ??????????????? CGI ??????? ???????? ?????????? ?????????????? ???? ?????? ???-???? (???? ???????????) ?? ?????? ??????????? ??????????. ? ????? ?????? ?????????? ???????????.

???????:
??? ???????? ????????? ??????? ????????:
RewriteCond %{REQUEST_FILENAME}   !-s
RewriteRule ^page.html$          page.cgi   [T=application/x-httpd-cgi,L]

?????, ?????? ? page.html ???????? ? ??????????? ??????? ???????????????? page.cgi ???? page.html ???-??? ??????????? ??? ????? ??????? ??????. ????? ????? ? ??? ??? page.cgi ??? ??????? CGI ?????? ??????? (? ?????????? ? ???????????? STDOUT) ?????????? ???? ????? ? ???? page.html. ???????? ??? ???? ???, ?????? ???????? ?????? page.html. ????? ????????? ????? ???????? ??????????, ?? ?????? ??????? page.html (?????? ? ??????? cronjob).

???????? ? ?????????????? ???????????

????????:

????? ??? ???? ?? ?? ??????? ??? ???????? ??????? ???????? ???? ?? ??????? ????????????? ???????? ??? ???????? ?????? ??? ????? ?? ??????? ????? ?? ?????? ? ????? ?????????? ???????????

???????:

???! ?? ?????? ???????????? ????? ?????????? MIME ???-???????, ????? NPH ?????????? ? ???? mod_rewrite ??? URL ???????????????. ???????, ?? ????????? ????? ????? URL: ??????? ?????????? :refresh ? ?????? URL ???????? ???????? ??? ?????????? ?????? ??? ????? ?????????? ??? ?????????? ? ???????? ???????.

RewriteRule   ^(/[uge]/[^/]+/?.*):refresh  /internal/cgi/apache/nph-refresh?f=$1

?????? ????? ?? ????????? ?? URL

/u/foo/bar/page.html:refresh

?????????? ?????????? ????? URL

/internal/cgi/apache/nph-refresh?f=/u/foo/bar/page.html

???????????? ????????????? ????? ??? NPH-CGI ??????. ???? ?????? ????????? ??? «??? ???????? ??? ????????? ????????» ;-) ? ????? ????? ??????? ? ???? ???.

#!/sw/bin/perl
##
##  nph-refresh -- NPH/CGI script for auto refreshing pages
##  Copyright (c) 1997 Ralf S. Engelschall, All Rights Reserved.
##
$| = 1;

#   split the QUERY_STRING variable

@pairs = split(/&/, $ENV{'QUERY_STRING'});
foreach $pair (@pairs) {
    ($name, $value) = split(/=/, $pair);
    $name =~ tr/A-Z/a-z/;
    $name = 'QS_' . $name;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    eval "$$name = "$value"";
}
$QS_s = 1 if ($QS_s eq '');
$QS_n = 3600 if ($QS_n eq '');
if ($QS_f eq '') {
    print "HTTP/1.0 200 OKn";
    print "Content-type: text/htmlnn";
    print "<b>ERROR</b>: No file givenn";
    exit(0);
}
if (! -f $QS_f) {
    print "HTTP/1.0 200 OKn";
    print "Content-type: text/htmlnn";
    print "<b>ERROR</b>: File $QS_f not foundn";
    exit(0);
}

sub print_http_headers_multipart_begin {
    print "HTTP/1.0 200 OKn";
    $bound = "ThisRandomString12345";
    print "Content-type: multipart/x-mixed-replace;boundary=$boundn";
    &print_http_headers_multipart_next;
}

sub print_http_headers_multipart_next {
    print "n--$boundn";
}

sub print_http_headers_multipart_end {
    print "n--$bound--n";
}

sub displayhtml {
    local($buffer) = @_;
    $len = length($buffer);
    print "Content-type: text/htmln";
    print "Content-length: $lennn";
    print $buffer;
}

sub readfile {
    local($file) = @_;
    local(*FP, $size, $buffer, $bytes);
    ($x, $x, $x, $x, $x, $x, $x, $size) = stat($file);
    $size = sprintf("%d", $size);
    open(FP, "<$file");
    $bytes = sysread(FP, $buffer, $size);
    close(FP);
    return $buffer;
}

$buffer = &readfile($QS_f);

&print_http_headers_multipart_begin;
&displayhtml($buffer);

sub mystat {
    local($file) = $_[0];
    local($time);

    ($x, $x, $x, $x, $x, $x, $x, $x, $x, $mtime) = stat($file);
    return $mtime;
}

$mtimeL = &mystat($QS_f);
$mtime = $mtime;
for ($n = 0; $n < $QS_n; $n++) {
    while (1) {
        $mtime = &mystat($QS_f);
        if ($mtime ne $mtimeL) {
            $mtimeL = $mtime;
            sleep(2);
            $buffer = &readfile($QS_f);
            &print_http_headers_multipart_next;
            &displayhtml($buffer);
            sleep(5);
            $mtimeL = &mystat($QS_f);
            last;
        }
        sleep($QS_s);
    }
}

&print_http_headers_multipart_end;

exit(0);

##EOF##

???????? ??????????? ???????

????????:

????? <VirtualHost> Apache ????? ?????? ? ??????????? ???????? ????? ? ??? ???? ??????? ??????????? ??????. ?????? ????? ? ????????? ISP ? ?????? ????? ??????????? ?????? ??? ???????? ?? ?????? ??????? ??? ????? ??????.

???????:

??? ??????? ???? ?????? ?? ???????? ?????????? ??????? ?? ??????????? ?????? ??? ???? ????????? ????? ???-???????????? ??????????? ??????, ? ????????? ? ????? ???????????? ????(????????? ????????? ???????) ? ?????????????? Proxy ??????? (???? [P]):

##
##  vhost.map
##
www.vhost1.dom:80  /path/to/docroot/vhost1
www.vhost2.dom:80  /path/to/docroot/vhost2
     :
www.vhostN.dom:80  /path/to/docroot/vhostN

##
##  httpd.conf
##
    :
#   ?????????? ???????????? ??? ????? ??? ??????????, ? ?.?.
UseCanonicalName on

    :
#   ????????? ??????? ??????????? ???? ??????? CLF
CustomLog  /path/to/access_log  "%{VHOST}e %h %l %u %t "%r" %>s %b"
    :

#   ???????? ???????? mod_rewrite ?? ???????? ???????
RewriteEngine on

#   ?????????? ??? ???????: ???? ??? ????????? URL ? ?????? ??? ???????????
#   ????????? ??????????? ?????? ? ???????????????
#   DocumentRoot.
RewriteMap    lowercase    int:tolower
RewriteMap    vhost        txt:/path/to/vhost.map

#   ?????? ?????? ???????? ?????????? ? ???????????? ???????
#   ????? ??????? ? ??????? ????????? ???????:
#
#   1. ????????? ??? ?? ?? ?????? ?????????? ? ???????????? URL
#	(?????????????? ????????? ???????)
RewriteCond   %{REQUEST_URL}  !^/commonurl1/.*
RewriteCond   %{REQUEST_URL}  !^/commonurl2/.*
    :
RewriteCond   %{REQUEST_URL}  !^/commonurlN/.*
#
#   2. ????????? ??? ?? ????? ????????? ?????, ?????? ???
#      ?????? ???? ???????????? ?????? ??? ????????????
#      ??????????? ??????? ????? ???? ?????????
RewriteCond   %{HTTP_HOST}  !^$
#
#   3. ????????? ??? ????? ? ?????? ???????
RewriteCond   ${lowercase:%{HTTP_HOST}|NONE}  ^(.+)$
#
#   4. ???? ??? ????? ????? ? vhost.map ?
#      ?????????? ??? ?????? ?????, ????? ??? ???????? ?????
#      (? ?? "NONE" ??. ????)
RewriteCond   ${vhost:%1}  ^(/.*)$
#
#   5. ??????? ?? ????? ????????????? ???? URL ? ??????????????? ??? ????????? 
#	   document root
#      ? ?????????? ??? ???????????? ????? ??? ?????? ? ??????
RewriteRule   ^/(.*)$   %1/$1  [E=VHOST:${lowercase:%{HTTP_HOST}}]
    :

??????????? ???????

???????????? ???????

????????:

??? ?? ????? ????????????? ????????????? ??????????? ??????? ?? ????????? ??????? ?? ????????????? ???????? ?????? ????? /robots.txt ??????????? ?????? «Robot Exclusion Protocol» ?????? ???????????? ??? ?????????? ?? ?????? ??????.

???????:

?? ?????????? ????? ?????? ??????????? ?????? ??? ??????? ? URL ?? ???-???????????? /~quux/foo/arc/ (???????? ??? ???????????? ????? ????? ???????? ???????? ?????????, ????? ??????? ???????, ?????? ?? ? ????? ??????? ???????? ?? ??????). ?? ?????? ????????? ??? ??????????? ?????? ?????? ??? ??????????? ??????, ?.?. ?????? ?????? ??? ????? ? ???????? ???????? ????? ????????????. ???, ????? ??????????? ?? ?????? ????????????? ? ????? ?????. ????? ??????? ?? ???????? ???????? ????? ?????????? ?? HTTP ?????????? User-Agent.

RewriteCond %{HTTP_USER_AGENT}   ^NameOfBadRobot.*
RewriteCond %{REMOTE_ADDR}       ^123.45.67.[8-9]$
RewriteRule ^/~quux/foo/arc/.+   -   [F]

???????????? ??????? ??????????? ??????

????????:

??????????? ??? ?? ????? ?? http://www.quux-corp.de/~quux/> ????????? ???????? ?? ??????? ? ??? ???? ??????????? ??????????? ? ??????? GIF. ??? ??????????? ??????????? ????? ??????, ??????? ?????? ????? ???????? ?? ?? ???? ???????? ????? ????? ???????????. ??? ?? ???????? ??? ???????? ?????? ??? ??? ????????? ??????????? ??????? ??? ?????? ???????.

???????:

? ?? ????? ??? ?? ?? ????? ?? 100% ???????? ???? ???????? ?? ??????? ?? ?????? ????????, ??, ?? ??????? ????, ????? ?????????? ?????? ? ??????? ??????? ???????? HTTP ????????? Referer.

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ! http://www.quux-corp.de/~quux/.*$ [NC]
RewriteRule .*.gif$        -                                    [F]
RewriteCond %{HTTP_REFERER}         !^$
RewriteCond %{HTTP_REFERER}         !.*/foo-with-gif.html$
RewriteRule ^inlined-in-foo.gif$   -                        [F]

?????? ?????

????????:

??? ?? ????? ????????? ?????? ? ?????? ??????? ??? ?????? ??????? ???????

???????:

??? Apache ?????? >= 1.3b6:

RewriteEngine on
RewriteMap    hosts-deny  txt:/path/to/hosts.deny
RewriteCond   ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND} !=NOT-FOUND [OR]
RewriteCond   ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND} !=NOT-FOUND
RewriteRule   ^/.*  -  [F]

??? Apache ?????? <= 1.3b6:

RewriteEngine on
RewriteMap    hosts-deny  txt:/path/to/hosts.deny
RewriteRule   ^/(.*)$ ${hosts-deny:%{REMOTE_HOST}|NOT-FOUND}/$1
RewriteRule   !^NOT-FOUND/.* - [F]
RewriteRule   ^NOT-FOUND/(.*)$ ${hosts-deny:%{REMOTE_ADDR}|NOT-FOUND}/$1
RewriteRule   !^NOT-FOUND/.* - [F]
RewriteRule   ^NOT-FOUND/(.*)$ /$1
##
##  hosts.deny
##
##  ????????! ??? ????????????? ??????, ? ?? ??????, ???? ???? ?? ??? ??????? ? ??????.
##             mod_rewrite ????? ?? ???? ???? ????/????????, ???????, ??? ?????? ??????,
##             ?????? ???? ???????????? ?? ??????? ???? ????????? ???????? "-".
##

193.102.180.41 - 
bsdti1.sdm.de  - 
192.76.162.40  - 

?????? Proxy

????????:

??? ?? ????? ????????? ??????????? ????? ??? ???? ???????????? ?? ???????????? ????? ???????????? proxy ?????? Apache?

???????:

??????? ?? ?????? ????????? ??? ????? mod_rewrite ????(!) ??? ????? mod_proxy ? ???????????????? ????? ??? ?????? Apache. ????? ??????? ?? ?????????? ????? mod_proxy . ????? ?? ??????????? ????????? ?????? ????????? ?? ?????...

RewriteCond %{REMOTE_HOST} ^badhost.mydomain.com$
RewriteRule ! http://[^/.].mydomain.com.*  - [F]

...? ????????? ?????? ????????? ?? ???????????? ? ??????????? ?????:

RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST}  ^badguy@badhost.mydomain.com$
RewriteRule ! http://[^/.].mydomain.com.*  - [F]

??????? ??????????? ????????????

????????:

?????? ?????????? ????? ??????????? ????????????, ???????? ???????????? ??????????? ?????????????? ? ?????? ?????? ?????????????. ?????? ??? ????? ????? ?????? ? ??????-???? ??????? ? ??? ???? ?? ?????? ???? ???? ??????? ????????????? ?????? ?????? ??? ???????????? (??????? ?????????? ??? ????????????? ??????? ???????????? ????? mod_auth_basic ).

???????:

?? ?????????? ?????? ??????? ??? ??? ?????????? ???? ????? ??????????? ???:

RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST} !^friend1@client1.quux-corp.com$
RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST} !^friend2@client2.quux-corp.com$
RewriteCond %{REMOTE_IDENT}@%{REMOTE_HOST} !^friend3@client3.quux-corp.com$
RewriteRule ^/~quux/only-for-friends/      -                                 [F]

?????????? ?????????? ?? HTTP ????????? Referer

????????:

??? ?? ????? ????????????????? ?????? ?????????? URL ??????? ???????? ????????? ?? HTTP ????????? «Referer» ? ????? ???? ???????? ?? ????? ?????????? ??????????? ???????, ????? ?? ??????

???????:

??????????? ?????????, ????????????? ?????????? ????? ??????...

RewriteMap  deflector txt:/path/to/deflector.map

RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}} ^-$
RewriteRule ^.* %{HTTP_REFERER} [R,L]

RewriteCond %{HTTP_REFERER} !=""
RewriteCond ${deflector:%{HTTP_REFERER}|NOT-FOUND} !=NOT-FOUND
RewriteRule ^.* ${deflector:%{HTTP_REFERER}} [R,L]

... ? ?????? ? ??????????????? ????????????? ???????? ??????????????:

##
##  deflector.map
##

 http://www.badguys.com/bad/index.html    - 
 http://www.badguys.com/bad/index2.html   - 
 http://www.badguys.com/bad/index3.html   http://somewhere.com/

??? ????????????? ???????????? ?????? ????? ?? ??????????? ???????? (????? «-» ???????????? ? ???????? ???????? ? ???????) ??? ?? ?????????? URL (????? ? ??????? ? ???????? ???????? ?????? ?????-???? URL).

??????

??????? ???????? ??????????????

????????:

????? ?????????? ??????: ??? ?? ????? ?????? ???????? FOO/BAR/QUUX/? ?.?.? ????? ??????? ??? ??????? ? ?????????????? mod_rewrite ...

???????:

????????????? ???????? ??????? RewriteMap , ?.?. ????????? ??????? ????????? ??? RewriteMap . ??? ??????????? ???? ??? ??? ?????? Apache, ???????? ??????????? URL ?? ??????? ????? ? ?????? ???????? ??????????????? URL (?????? ???????????????) ? ???????? ????? (? ??? ?? ????? ???????!).

RewriteEngine on
RewriteMap    quux-map       prg:/path/to/map.quux.pl
RewriteRule   ^/~quux/(.*)$  /~quux/${quux-map:$1}
#!/path/to/perl

#   ?????????? ???????????????? I/O ??????? ?????? ??
#   ? ???????????? ???????????? ? ????????? Apache
$| = 1;

#   ?????? URL ???? ? ?????? ?? ???????? ?????? ?
#   ????????? URL ??? ??????????? ? ???????? ?????
while (<>) {
    s|^foo/|bar/|;
    print $_;
}

??? ?????? ???????????????? ?????? ? ??? ?????? ??? URL /~quux/foo/... ????????????? ? /~quux/bar/.... ? ???????????????? ?? ?????? ????????????????? ????? ??? ??? ??????. ??????? ?? ????????, ??? ???? ????? ??????? ? ????? ???? ????????????, ? ??? ????? ? ??????? ?????????????, ?????? ?????????? ?? ????? ?????? ????????? ?????????????.






 ???????? ?????????? ? ??????? ?????? ? .htaccess
 ?????? Apache ? chroot ?????????
 ?????? Apache ? jail environment ??? FreeBSD


Внимание! Читая пророчества на этом сайте помните что достоверность трудно проверить и все может во времени изменяться
"О дне же том, или часе, никто не знает, ни Ангелы небесные, ни Сын, но только Отец (Мк. 13, 32)"