cosminkent Posted April 2, 2014 Report Posted April 2, 2014 Create Custom Error PagesErrorDocument 400 / error/400.htmlErrorDocument 401 / error/401.htmlErrorDocument 403 / error/403.htmlErrorDocument 404 / error/404.htmlErrorDocument 500 / error/500.htmlForce download of specific types of file<Files *.mp3> ForceType application / octet-stream September Header Content-Disposition attachment</ Files><Files *.xls> ForceType application / octet-stream September Header Content-Disposition attachment</ Files>Prevent HotlinkingRewriteEngine On# Changed? Mysite.com / with the url of our siteRewriteCond% {HTTP_REFERER}! ^ Http:// (. +.)? Mysite.com / [NC]RewriteCond% {HTTP_REFERER}! ^ $# Changed / images / nohotlink.jpg with an image that indicates that we do not tolerate the hotlinks$ / Images / nohotlink.jpg [L] RewriteRule * (png jpe g |? Gif | | bmp)..Using the cache to increase the speed of our site# 1 Year<FilesMatch ".(ico|pdf|flv)$">September Header Cache-Control "max-age = 29030400, public"</ FilesMatch># 1 Week<FilesMatch ".(jpg|jpeg|png|gif|swf)$">September Header Cache-Control "max-age = 604800, public"</ FilesMatch># 2 Days<FilesMatch ".(xml|txt|css|js)$">September Header Cache-Control "max-age = 172800, proxy-revalidate"</ FilesMatch># 1 Minutes<FilesMatch ".(html|htm|php)$">September Header Cache-Control "max-age = 60, private, proxy-revalidate"</ FilesMatch>Create a blacklist of IP addressesGET POST <Limit PUT>order allow, denyallow from alldeny from 123.123.123.1deny from 555.555.555.5deny from 000.000.000.0</ Limit>Create a PHP error log# Prevent display errors to the userdisplay_startup_errors off php_flagphp_flag display_errors offhtml_errors off php_flag# Log errors in the logphp_flag log_errors onphp_value error_log / logs / php_error.logRedirect mobile devicesRewriteEngine OnRewriteCond% {REQUEST_URI}! ^ / M /. $RewriteCond% {HTTP_ACCEPT} "text / vnd.wap.wml | application / vnd.wap.xhtml + xml" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "acs | alav | alkaline | amoi | audi | aste | avan | benq | bird | blac | blaz | brew | cell | cldc | cmd-" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "dang | doco | eric | HIPT | inno | ipaq | java | jigs | kddi | keji | leno | lg-c | lg-d | lg-g | lge-" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "maui | maxo | midp | mits | MMEF | mobi | mot-| moto | MWBP | nec-| newt | noki | OPWV" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "palm | pana | pant | pdxg | phil | play | pluc | port | prox | qtek | qwap | sage | sams | sany" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "sch-| sec-| send | seri | sgh-| shar | sie-| siem | smal | smar | sony | sph-| symb | ??t-mo" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "teli | tim-| tosh | tsm-| UPG1 | UPSI | vk-v | voda | W3C's | wap-| wapa | wapi" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "wapp | wapr | webc | winw | winw | xda | xda-" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "UP.Browser | UP.Link | windowssce | iemobile | mini | mmp" [NC, OR]RewriteCond% {HTTP_USER_AGENT} "symbian | midp | wap | phone | pocket | mobile | pda | psp" [NC]# ------------- The line below excludes the iPad from the listRewriteCond% {HTTP_USER_AGENT}! ^. * IPad. * $ # -------------RewriteCond% {HTTP_USER_AGENT}! Macintosh [NC] # * SEE NOTE BELOWRewriteRule ^ (. *) $ / M / [L, R = 302]Support for video in HTML5RewriteCond% {REQUEST_FILENAME}!-FRewriteCond% {REQUEST_FILENAME}!-DRewriteCond% {REQUEST_URI}! = / Favicon.icoAddType video / ogg. OgvAddType video / ogg. OggAddType video/mp4. Mp4AddType video / webm. WebmAddType application / x-shockwave-flash swf301 RedirectsRedirect 301 / d / file.html http://www.domainname.com/r/file.htmlTo protect a specific file<Files Wp-config.php>order allow, denydeny from all</ Files>Password protect a directory# Password protecting a filesecure.php=""> <FilesAuthType BasicAuthName "Prompt"AuthUserFile / home / path / htpasswdRequire valid-user</ Files># Password-protect a directoryresideAuthType basicAuthName "This directory is protected"AuthUserFile / home / path / htpasswdAuthGroupFile / dev / nullRequire valid-userRemover www URLs of your site# Remove www from URLRewriteEngine OnRewriteCond% {HTTP_HOST} ^ www \. Domain \. Com $ [NC]RewriteRule ^ (. *) $ Http://domain.com/ $ 1 [L, R = 301]Source: uc0 Quote
behave Posted April 2, 2014 Report Posted April 2, 2014 Foarte bine facut articolul.Totusi as avea ceva de subliniat pt cei care intentioneaza sa-l foloseasca:htaccess este "greoi", de aceea daca sunteti pe shared hosting (si aveti acces doar la htaccess) sa va ganditi ca unele actiuni pot fi obtinute cu php care de cele mai multe ori este mai rapid decat htaccess. Quote