/home/st1331/
|
+-->
| |
| +-- .htaccess
| |
| +-- /www/news/
| | |
| | +-- .htaccess
| | +-- main.html
| | |
| | + /www/news/2003.10/
| | | |
| | | + .htaccess
| | |
| | + /www/news/2003.11/
| |
| +-- /www/data/
| | |
| | +-- .htaccess
| | +-- .htpasswd
| |
| +-- /www/images/
|
+-- /home/st1331/cgi-bin (??? cgi ????????)
|
+-- /log (?????????)
|
+-- /stats (?????????)
???????? .htaccess ????????????? ???????????????? ?? ??? ????????? ??????????.
????? ??????? ????? ??????????? ????????? ????? .htaccess:
?????????? | ??????????? .htaccess |
/www/ |
/www/.htaccess |
/www/news/ |
/www/.htaccess
/www/news/.htaccess |
/www/news/2003.10/ |
/www/.htaccess
/www/news/.htaccess
/www/news/2003.10/.htaccess |
/www/news/2003.11/ |
/www/.htaccess
/www/news/.htaccess
|
/www/data/ |
/www/.htaccess
/www/data/.htaccess |
/www/images/ |
/www/.htaccess |
??????? ????????? .htaccess
• ???? ? ?????? (???????????) ??????????? ?? ????? ???????.
?????????? ??????:
DirectoryIndex /home/st1331/www/data/main.html
??????:
DirectoryIndex /www/news/main.html
• ????????? ? ??????????, ????????????? ?? ?????? ?????? ??????
??????????? ? ????????? ?????????
?????????? ??????:
Redirect /oldsite/ http://www.site.ru/
??????:
Redirect /oldsite/ www.site.ru/
??????????? - ??????, ???????????? ? ??????? #
.
? ?????????? ????? ???????????? ?????????? ?????????,
???????? %{REMOTE_ADDR} ??? %{HTTP_REFERER}.
• ???? .htaccess ?????? ???? ??????? ? UNIX-??????? — ???
???????? ??? ??????? ?????? ?????? ?????????? ? ??? ????? ????????
(0x0A
), ? ?? ????? (0x0D 0x0A
), ??? ? DOS ???
Windows
<!----------------------------------------------------------------------------------------------->
??????????? ??????? ???????? ????????
????????? Files
?????????: ???????? Files
???????????? ???????? ???????? ????? ??????
Syntax: <Files filename> ... </Files>
filename
??? ?????
??????:
<Files my_secure_document.html>
Order Deny,Allow
Deny from all
Allow from 192.168.1.1
</Files>
????????? FilesMatch
?????????: ???????? Files
???????????? ???????? ???????? ????? ??????
Syntax: <Files regex> ... </Files>
regexp
: ?????????? ????????? (??????), ??????????? ?????? ??????.
??????:
<FilesMatch ".(gif|jpe?g|png)$">
Order Allow,Deny
Allow from all
Deny from 192.168.1.1
</Files>
<!---------------------------------------------------------------------------------------------->
??????????????? (?????????)
????????? Redirect
????????: ????????? ???????? ??????????, ?????????????? ???????? ?? ??????
URL. ????????? ??????? ???????? (??????? ???????? ? ?????????????
????????? ?????? URL).
?????????: Redirect [status] URL-path
URL
status
: ?????????????? ????,
?????????? ??? ????????, ?????????? ????????: permanent
(301
— ???????? ????????? ?????????), temp
(302
— ???????? ????????? ????????), seeother
(303
— ???????? ??????), gone
(410
— ?????).
URL-path
: ????????? ????? URL ?????????????? ?????????.
URL
: URL ???? ?????? ???? ???????? ????????
Redirect temp / http://www.iho.ru/newyear.html
Redirect temp /index.html http://www.iho.ru/newyear.html
Redirect permanent /prices2002.html http://www.iho.ru/prices2003.html
????????? RedirectMatch
????????: ????????? ???????? ??????????, ?????????????? ???????? ?? ??????
URL. ????????? ??????? ???????? (??????? ???????? ? ?????????????
????????? ?????? URL). ????????? ?????????? Redirect
, ?? ??????????? ????, ???
?????? ?????? ?????????????? ????????? ??????? ?????????? ????????? (??????)
?????????: Redirect [status] regexp URL
status
: ?????????????? ????,
?????????? ??? ????????, ?????????? ????????: permanent
(301
— ???????? ????????? ?????????), temp
(302
— ???????? ????????? ????????), seeother
(303
— ???????? ??????), gone
(410
— ?????).
URL-path
: ????????? ????? URL ?????????????? ?????????.
regexp
: ?????????? ????????? (??????), ??????????? ?????? URL-??.
RedirectMatch (.*).gif$ http://www.myserver.com$1.png
RedirectMatch (.*.jpg)$ http://www.myanother.com$1
??????: ?????? ????????, ? ??????????? ?? IP ?????? ??????????. ? ???????
?????????? ? ?????? 192.168.1.1
???????????????? ?? ?????? ????????
RewriteCond %{REMOTE_ADDR} 192.168.1.1
RewriteRule ^/$ /anoter_index_pahe.html [L]
??????: ?????? ????????, ? ??????????? ?? ??????????? ????????. ? ???????
??????????, ?????????? ?? ???????? http://www.partner.ru/
> ??????
/prices.html
???????? /anoter_prices.html
RewriteCond %{HTTP_REFERER} http://www.partner.ru/recep.html
RewriteRule ^/prices.html$ /anoter_prices.html [L]
??????????????? ?????????? ??? ??????? ???????????? ???????:
??? ??? ??? ???? ??????? ??????? ? ????????. ?????? ????? ?????? ? ???????
/_vti_bin ????? ????????????? ???????????????? ?? Microsoft:
redirect /_vti_bin http://www.microsoft.com
redirect /scripts http://www.microsoft.com
redirect /MSADC http://www.microsoft.com
redirect /c http://www.microsoft.com
redirect /d http://www.microsoft.com
redirect /_mem_bin http://www.microsoft.com
redirect /msadc http://www.microsoft.com
RedirectMatch (.*)cmd.exe$ http://www.microsoft.com$1
<!----------------------------------------------------------------------------------------------->
??????????? ??????? (??????)
????????? Order
????????: ????????????? ??????? ?????? ???????? Deny
? Allow
?????????: Order ???????
???????
????? ????????? ????????
Deny,Allow
??? Allow,Deny
?? ?????????: Order Deny,Allow
????????? Deny
????????: ????????? ?????? ???????????? ???????? ? ????????.
?????????: Deny from all|host
host
????? ????????? ???????? IP ?????? ??? ????? ?????.
????????? Allow
????????: ????????? ?????? ???????????? ???????? ? ????????.
?????????: Deny from all|host
host
????? ????????? ???????? IP ?????? ??? ????? ?????.
??????: ?????? ?? ?????? ??? ????
Order Deny,Allow
Deny from all
??????: ?????????? ?? ?????? ??? ???????????? IP ???????
Order Deny,Allow
Deny from all
Allow from .iho.ru
Allow from 192.168.1.1
??????: ?????? ?? ?????? ??? ???? ?? ??????????? ???????????? IP ???????
Order Allow,Deny
Allow from all
Deny from .iho.ru
Deny from 192.168.1.1
??????: ?????? ?? ?????? ??? ???????????? ????. ? ??????? ??????????? ??????
? ????? .htpasswd
??? ???? ???????????
<Files ".htpasswd">
Order Deny,Allow
Deny from all
</Files>
??????: ?????? ?? ?????? ??? ???????????? ?????? ??????. ? ???????
??????????? ?????? ? ?????? ? ???????????? "lib" ? "pm" ??? ???? ???????????
<FilesMatch ".(lib|pm)$">
Order Deny,Allow
Deny from all
</FilesMatch>
<!---------------------------------------------------------------------------------------------->
????????? ?????? ?? ??????
????????? AuthName
????????: ???????? AuthName
????? ?????????? ??? ?????????? ? ????? ?????????????? ???
????????? ??????? ???????????.
????????? AuthType
????????: ??? ????????? ???????? ??? ??????????????. ???????? ????????? ????:
Basic
and Digest
.
?????????: AuthType Basic|Digest
????????? AuthUserFile
????????: ???????? AuthUserFile
????????? ??? ????? ? ????????
??? ?????????????? ?????????????. ???? ? ???????? ????? ???? ??????? ????????
htpasswd
. ???? ? ????? ? ???????? ???????? ???????????? ?????
???-???????. ??????? ???? ? ???????? ? ?????, ?????? ? ??????? ??????
??? ?????????????..
?????????: AuthUserFile ????-?-?????
????????? Require
????????: ?????????? ?????????????, ??????? ????? ???????? ??????
?????????: Require ???-????????????|valid-user
???????? valid-user
?? ?????????? ?????? ???? ?????????????,
????????????? ? ????? ???????.
??????: ????????? ?????? ?????????? ???? ?????????????:
AuthName "Restricted area"
AuthType Basic
AuthUserFile /home/st1331/www/data/.htpasswd
Require valid-user
??????: ????????? ?????? ? ?????????? ?????? 3-? ?????????????:
AuthName "Very restricted area"
AuthType Basic
AuthUserFile /home/st1331/www/data/.htpasswd
Require antonio solo marina
??????: ??????????? ??????? ? ???????????? ?????? (? ???? ??????? ?????????
?????? ? zip ???????)
<FilesMatch ".zip$">
AuthName "Only valid users can download zip files."
AuthType Basic
AuthUserFile /home/st1331/www/data/.htpasswd
Require valid-user
</FilesMatch>
??????: ??????????? ??????? ? ?????? ????? (? ???? ??????? ?????????
?????? ? ????? .htpasswd)
<Files ".htpasswd">
AuthName "Access restricted."
AuthType Basic
AuthUserFile /home/st1331/www/data/.htpasswd
Require antonio solo
</Files>
<!----------------------------------------------------------------------------------------------->
?????????? ????????
????????? DirectoryIndex - ????????? ???????? ?? ????????? (?????????)
????????: ????????? ???????? ????????, ??????? ????? ???????????? ??? ????????? ? ??????????
?????????: DirectoryIndex page [page]
page
- ???????? ????????? ????????. ????? ???? ??????? ????????? ???????.
??????:
DirectoryIndex main.html index.php test.shtml
????????? ErrorDocument - ????????? ??????
????????: ????????? ????????????? ?????????????? ???????? ??????
?????????: ErrorDocument code URL-path
URL-path
- ????????? ????? ????????
code - ??? ??????. ???????? ???????? ???? ???????:
401 — ????????? ??????????? (Authorization Required)
403 — ???????????? ?? ?????? ??????????????, ?????? ?? ?????? (Forbided)
404 — ????????????? ???????? (????, ??????????) ?? ?????? (Not Found)
500 — ?????????? ?????? ??????? — ?????? ??????? ??? ?????? ? ?????????? ????? .htaccess - (Internal Server Error)
ErrorDocument 401 /401.html
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
????????? AddOutputFilter - ????????? ??????? (SSI)
<FilesMatch ".(mytype)$">
SetOutputFilter INCLUDES
</Directory>
????????? SetHandler - ????????? ??????????? (PHP, Parser)
????????: ????????????? ?????????? ??? ?????? ? ???????? ??????????
?????????: SetHandler handler-name
SetHandler php-script
????????? AddHandler - ????????? ??????????? (PHP, Parser)
????????: ????????????? ?????????? ??? ?????? ?????????? ????
?????????: AddHandler handler-name filename-extension
AddHandler php-script .html
AddHandler parser-script .htm
????????? AddDefaultCharset - ????????? ??????????? (PHP, Parser)
?? ????????? ?? ??????? ??????????? ????????? Windows-1251
AddDefaultCharset koi8-r
<!---------------------------------------------------------------------------------------------->
??? ????????? ???? ???????????? SSI ??????????
SSI ????????? "????????" ???????? ?? ????????. ? ????? ??????? ? ??? ??? ????, ?
?????? ??? ??????? ????? ????????, ? ??????? - ??????. ? ?????????? ?????
??????? ????????, ??????? ??????? ?? ???? ????, ??????? ?????? ? ???? ???????.
?????????? ???????????? ????????? ? httpd.conf: ? ?????, ???????????? ?
<Directory/> ? ??????????????? </Directory> ? ?????? Options Indexes
???????? Includes. ?????, ? ????? .htaccess ?????:
AddOutputFilter Includes .html .htm
??? ????????? ?????? ?? ??????????? ??????????? ?????????? ??? ?????????? ?????????? ??????
???????????, ??? ? ??? ??? ???????, ???????????? ?? ????? ????????? ? ??????????
img. ?????????? ????? ??????? ? ???????? ?????? ???????? ??? ?????????? ?
??????? ?????? ???? ????? ??????????? ??????. ???????, ??? ?? ??????? ??? ?????,
?? ????? ? ?? ???? ?????? ????????? ??????????. ? .htaccess ?????:
<!----------------------------------------------------------------------------------------------->
htpasswd
????????? htpasswd ?????? ??? ???????? ????? ? ????????, ??????? ????? ????
??????????? ??? ?????????????? ????????????? ???-????????.
??????: ???????? ????? ? ???????? ? ?????????? ? ???? 1 ?????:
htpasswd -c Filename username
??????: ?????????? ??? ????????? ????? ? ????????
htpasswd Filename username2
<!---------------------------------------------------------------------------------------------->
??????? ???? .htaccess, ? ?????? ?????? ?????? 500 ??????. ???????
500-? ?????? ????? ???? ??????? ?????????? ?????????:
1. ???????? ????????? .htaccess
2. ???? .htaccess ??????? ? ??????? Windows, ? ?????? ???? ??????? ? ??????? UNIX