Apache Configs
Contents |
Control Files
.htaccess
Note: We can't block hotlinked GIFs, 'cause we're using a GIF to substitute. That's okay, though, 'cause none of the GIFs are big enough to be a bandwidth issue.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?greyduck.net(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://([-a-z0-9]+\.)?google.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?kylanath.net(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?radicalbender.com(/)?.*$ [NC]
RewriteRule .*\.(jpg|jpeg|png)$ http://greyduck.net/images/Hotlinking.gif [R,NC]
The point of this exercise is to allow all greyduck.net (for myself and my cohosted cohorts) and google.com (for Google image searches) subdomains as well as kylanath.net (another cohort) and radicalbender.com (where I have a gd.net-hosted image as my avatar in the forums), but everyone else gets Dawn's lovely "Hotlinking" image. Yay!
Simple redirects can be done with the following line in .htaccess:
redirect /archives http://tinkrbel.greyduck.net/
(Sample taken from Mari's Thingie.)
And another bit o' fun, redirecting non-SSL accesses to the SSL variant:
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://www.domain.com/folder/$1 [L,R]
Yes, we'll be looking into that. Soon.
robots.txt
Yahoo's Slurp sucks up a fair chunk o' bandwidth. Here's how we slow that down a bit, according to their FAQ:
User-agent: Slurp Crawl-delay: 5
It can go as high as 10, which we may try at some point. Also, because Gigabot is a pain in the neck:
User-agent: Gigabot Disallow: /
That's right, we make it go away entirely.
Output Compression
Related to those damned robots, here's a way we might end up compressing output to lower bandwidth usage. Either in the main body of httpd.conf or in a given VirtualHost section, insert some combination of the following:
# Method 1: Only compress specified content type
<Location />
<IfModule mod_deflate.c>
# compress content with type html, text, and css
AddOutputFilterByType DEFLATE text/html text/plain text/css
<IfModule mod_headers.c>
# properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
</Location>
Or...
# Method 2: Compress all content, manually excluding specified file types
<IfModule mod_deflate.c>
# place filter 'DEFLATE' on all outgoing content
SetOutputFilter DEFLATE
# exclude uncompressible content via file type
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|rar|zip)$ no-gzip
<IfModule mod_headers.c>
# properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
And also...
# Properly handle old browsers that do not support compression <IfModule mod_deflate.c> BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule>
Optionally, for AWstats' sake...
# deflate.log, log compression ratio on each request
<IfModule mod_deflate.c>
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate.log deflate
</IfModule>
Note that we'll need to tweak these configs for our actual use. (For instance we have some filetypes that don't want recompressing, such as mp3 and ogg, to add.) This info is purely speculative at the current time.
favicon.ico
Irfanview can save files in ICO format, so all we need is a 256-color 32x32 image to make those 404 errors go away...