############################################################################### ## The Master .htaccess ## ## Version 2.5 (proposed) - May 16th, 2011 ## ## ---------- ## This file is designed to be the template .htaccess file to put on your new ## sites, increasing your site's security and performance. It is not meant to ## be just dropped in your site, though. You should go through all of its ## sections and modify it to match your site. Most notably, all instances of ## example.com and example\.com should be replaced with your real domain name. ## ## Some sections are too picky and may cause problems with legitimate requests. ## You are ultimately responsible for disabling them or writing exception rules ## for your requests. Most notably, the advanced server protection section will ## cause issues with several minifiers, eXtplorer, VirtueMart and other exten- ## sions which use non-standard scripts as their entry points. You must add ## exceptions for them manually. ## ## Some sections - depending on your server configuration - may cause your site ## to throw 500 Internal Server Error. The only way to figure out which one is ## causing it is trial and error. ## ## Big thank you's to Brian Teeman, Ken Crowder, Radek Suski and Fotis ## Evangelou for sharing their .htaccess rules with the world and inspiring ## the creation of this file. Special thanks to Jon Brown for sharing his ## research and helping me improve this file. ## ## Additional thank-yous to John for his remarks and g1smd for taking the ## time to optimize the speed of the file. ## ## It is usually prudent to remove the comments from the file when using it ## on a live host to minimize the parsing time. ## ## ---------------------------------------------------------------------- ## Do you want to customize this .htaccess file with a few clicks? ## Admin Tools Professional by AkeebaBackup.com does this and much more. ## ## Learn more: http://www.akeebabackup.com/software/admin-tools.html ## ---------------------------------------------------------------------- ## ## Have fun, stay safe. ## ## Nicholas K. Dionysopoulos ## Lead Developer, AkeebaBackup.com ## ## CHANGELOG: ## Version 2.5 (proposed) (May 16th, 2011) ## - Placeholders for custom code. Correction of ruleset ordering. ## Version 2.4 (April 18th, 2011) ## - Dozens of speed optimisations and many logic and syntax corrections. ## Version 2.3 (November 18th, 2010) ## - Added .ico to the pass-through rules, for favicons to load ## Version 2.2 (October 25th, 2010) ## - Bug in the tmpl=component rule ## Version 2.1 (October 19th, 2010) ## - index.php to root redirection would kill some AJAX requests ## - Referer filtering was screwed up ## - Simplified and more thorough PHP Easter Egg code (thanks Jon!) ## - The tp/template/tmpl filter was not thorough and killed some components ## - Optimized Joomla! core SEF section ## - Bot filters and GZip optimization would never run for dynamic content ## - Content expiration optimization got more optimized ## - Added ETag rule ## ############################################################################### ########## Begin - RewriteEngine enabled RewriteEngine On ########## End - RewriteEngine enabled ########## Begin - RewriteBase # Uncomment following line if your webserver's URL # is not directly related to physical file paths. # Update Your Joomla! Directory (just / for root) # RewriteBase / ########## End - RewriteBase ########## Begin - No directory listings ## Note: +FollowSymlinks may cause problems and you might have to remove it IndexIgnore * Options +FollowSymLinks All -Indexes ########## End - No directory listings ########## Begin - File execution order, by Komra.de DirectoryIndex index.php index.html ########## End - File execution order ########## Begin - ETag Optimization ## This rule will create an ETag for files based only on the modification ## timestamp and their size. This works wonders if you are using rsync'ed ## servers, where the inode number of identical files differs. ## Note: It may cause problems on your server and you may need to remove it FileETag MTime Size ########## End - ETag Optimization ########## Begin - Common hacking tools and bandwidth hoggers block ## By SigSiu.net and @nikosdion. # This line also disables Akeeba Remote Control 2.5 and earlier SetEnvIf user-agent "Indy Library" stayout=1 # WARNING: Disabling wget will also block the most common method for # running CRON jobs. Remove if you have issues with CRON jobs. SetEnvIf user-agent "Wget" stayout=1 # The following rules are for bandwidth-hogging download tools SetEnvIf user-agent "libwww-perl" stayout=1 SetEnvIf user-agent "Download Demon" stayout=1 SetEnvIf user-agent "GetRight" stayout=1 SetEnvIf user-agent "GetWeb!" stayout=1 SetEnvIf user-agent "Go!Zilla" stayout=1 SetEnvIf user-agent "Go-Ahead-Got-It" stayout=1 SetEnvIf user-agent "GrabNet" stayout=1 SetEnvIf user-agent "TurnitinBot" stayout=1 # This line denies access to all of the above tools deny from env=stayout ########## End - Common hacking tools and bandwidth hoggers block ########## Begin - Automatic compression of resources # Compress text, html, javascript, css, xml, kudos to Komra.de # May kill access to your site for old versions of Internet Explorer # The server needs to be compiled with mod_deflate otherwise it will send HTTP 500 Error. # mod_deflate is not available on Apache 1.x series. Can only be used with Apache 2.x server. # AddOutputFilterByType is now deprecated by Apache. Use mod_filter in the future. AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript ########## End - Automatic compression of resources ########## Begin - Add optional bad user agent or IP blocking code # # If you need to block certain user agents or IP addresses and # other signatures, place that code here. Ensure the rules use # the correct RewriteRule syntax and the [F] flag. # ########## End - Add optional bad user agent or IP blocking code ########## Begin - Rewrite rules to block out some common exploits ## If you experience problems on your site block out the operations listed below ## This attempts to block the most common type of exploit `attempts` to Joomla! # # If the request query string contains /proc/self/environ (by SigSiu.net) RewriteCond %{QUERY_STRING} proc/self/environ [OR] # Block out any script trying to set a mosConfig value through the URL # (these attacks wouldn't work w/out Joomla! 1.5's Legacy Mode plugin) RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] # Block out any script trying to base64_encode or base64_decode data within the URL RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [OR] ## IMPORTANT: If the above line throws an HTTP 500 error, replace it with these 2 lines: # RewriteCond %{QUERY_STRING} base64_encode\(.*\) [OR] # RewriteCond %{QUERY_STRING} base64_decode\(.*\) [OR] # Block out any script that includes a